#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

typedef long long ll;
typedef pair<int,ll> P;

#define fs first
#define sc second

const ll inf = (ll)1e15;
P par[9];
int rank[9];
 
void init(int n){
  for(int i=0;i<n;i++)par[i] = P(i,0);
}
 
P find(int a){
  if(par[a].fs == a)return par[a];
  P tmp = find(par[a].fs);
  return par[a] = P(tmp.fs,tmp.sc + par[a].sc);
}
 
bool same(int a,int b){
  return (find(a).fs == find(b).fs);
}
 
bool unite(int a,int b,ll cost){
  P x = find(a);
  P y = find(b);
   
  if(same(x.fs,y.fs)){
    if(y.sc - x.sc != cost)return false;
  }else{
    if(rank[x.fs]<rank[y.fs]){
      par[x.fs] = P(y.fs,y.sc-x.sc-cost);
    }else{
      par[y.fs] = P(x.fs,x.sc-y.sc+cost);
      if(rank[x.fs] == rank[y.fs])rank[x.fs]++;
    }
  }
  return true;
}

ll dis(int a, int b){
  if(!same(a,b))return inf;
  return par[b].sc - par[a].sc;
}

ll dist;
int n,m;
ll s[9],d[9];

ll rec(vector<int> v, int depth){
  if(depth == m){
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
	if(dis(i,j)<=0)return inf;

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(v[i]<v[j]){
	  if(s[v[i]] <= s[v[j]])continue;
	  if(!same(v[i],v[j]))continue;
	  if(dist * (s[v[i]]-s[v[j]]) <= dis(v[i],v[j]))continue;
	  return inf;
	}else{
	  bool f = false;
	  for(int k=0;k<m;k++)f |= (d[k]*(s[v[j]] - s[v[i]]) == dis(v[j],v[i]));
	  if(!f)return inf;
	}
      }
    }
    
    ll goal[9],start[9];
    vector<int> pos(n);
    for(int i=0;i<n;i++)pos[v[i]] = i;

    for(int i=0;i<n;i++){
      if(!i){
	start[i] = 0;
	goal[i] = s[i]*dist;
      }else{
	if(same(i-1,i))start[i] = start[i-1] + dis(i-1,i);
	else start[i] = start[i-1] + 1;
	goal[i] = start[i] + s[i]*dist;
	for(int j=0;j<i;j++){
	  if(pos[j]<pos[i] && goal[j]>goal[i]){
	    start[i] += goal[j]-goal[i];
	    goal[i] = goal[j];
	  }
	}
	for(int j=0;j<i;j++){
	  if(same(i,j)){
	    start[j] = start[i] + dis(i,j);
	    goal[j] = start[j] + s[j]*dist;
	  }
	}
      }
    }
    
    ll res = 0;
    for(int i=0;i<n;i++)res = max(res,goal[i]);
    return res;
  }
  
  ll res = inf;
  P tp1[9],tp2[9];
  int tr1[9],tr2[9];

  res = min(res,rec(v,depth+1));

  for(int i=0;i<n-1;i++){
    if(v[i] < v[i+1] && s[v[i]] > s[v[i+1]]){
      for(int x=0;x<n;x++){
	tp1[x] = par[x];
	tr1[x] = rank[x];
      }
 
      ll t1 = (s[v[i]]-s[v[i+1]])*d[depth];
      if(!unite(v[i],v[i+1],t1))continue;

      swap(v[i],v[i+1]);
      
      res = min(res,rec(v,depth+1));
      
      for(int j=i+2;j<n-1;j++){
	if(v[j] < v[j+1] && s[v[j]] > s[v[j+1]]){
	  for(int x=0;x<n;x++){
	    tp2[x] = par[x];
	    tr2[x] = rank[x];
	  }
	  
	  ll t2 = (s[v[j]]-s[v[j+1]])*d[depth];
	  if(!unite(v[j],v[j+1],t2))continue;

	  swap(v[j],v[j+1]);
	  
	  res = min(res,rec(v,depth+1));
	  
	  swap(v[j],v[j+1]);
	  for(int x=0;x<n;x++){
	    par[x] = tp2[x];
	    rank[x] = tr2[x];
	  }
	}
      }
      swap(v[i],v[i+1]);
     
      for(int x=0;x<n;x++){
	par[x] = tp1[x];
	rank[x] = tr1[x];
      }
    }
  }
  return res;
}

int main(){
  cin >> dist >> n;
  for(int i=0;i<n;i++)cin >> s[i];
  cin >> m;
  for(int i=0;i<m;i++)cin >> d[i];
  sort(d,d+m);

  vector<int> v(n);
  for(int i=0;i<n;i++)v[i] = i;

  init(n);
  cout << rec(v,0) << endl;
}

Measured memory_bytes: 1220