#include<bits/stdc++.h>
using namespace std;
double L[50005];
int p=0,g,v[25],n,i,j,k,a[25];
double d,s,t;
int fMin,fMax;
int F(int x)
{
  return x*x;
}
void Cal(int x)
{
  x--;
  double S=s+(x+2)*t;
  int i,j,k;
  if(x==0)
   {
     S+=sqrt(F((n-1)*d)+F(s))*2;
   }
  else {
    for(i=1;i<x;i++)
     S+=sqrt(F((a[i+1]-a[i])*d)+F(s))*2;
       S+=sqrt(F((a[1]-1)*d)+F(s))*2;
            S+=sqrt(F((n-a[x])*d)+F(s))*2;
  }cout<<S<<endl;
  L[++p]=S;
}
void DFS(int x)
{
  int i,j,k;
  Cal(x);
  if(x>n-2) return;
  for(i=2;i<n;i++)
   if(!v[i])
   {
    a[x]=i;v[i]=1;
    DFS(x+1);
    v[i]=0;
   }
}
int main()
{
 cin>>n>>d>>s>>t>>fMin>>fMax;
 DFS(1);
 sort(L+1,L+p+1);
 while(cin>>g)
 {
  int r=g-2*fMin,l=g-2*fMax;
  l=lower_bound(L+1,L+p+1,l)-L;
  r=lower_bound(L+1,L+p+1,r)-L;
  while(L[r]>g-2*fMin) r--;
  printf("%d\n",r-l+1);
 }
  return 0;
}
