#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const long long int My_LInf=9223372036854775807;


struct aUnionFind {
	vector<pair<int, long long int>> data;
	aUnionFind(int size) : data(size, make_pair(-1, 0)) { }

	//y is w bigger than x
	bool unionSet(const int x, const int y, const long long int w) {
		const int rx(root(x).first), ry(root(y).first);
		if (rx != ry) {
			data[rx].first += data[ry].first; data[ry].first = rx;
			data[ry].second = w + data[x].second - data[y].second;
			return true;
		}
		else {
			return root(x).second + w == root(y).second;
		}
	}
	bool findSet(const int x, const int y) {
		return root(x) == root(y);
	}

	//x is belong to first
	//x is second bigger than first
	pair<int, long long int> root(const int x) {
		if (data[x].first < 0) {
			return make_pair(x, 0);
		}
		else {
			pair<int, long long int>ndata;
			ndata.first = root(data[x].first).first;
			ndata.second = data[x].second + root(data[x].first).second;
			return data[x] = ndata;
		}
	}
	int size(const int x) {
		return -data[root(x).first].first;
	}
};


int HorseNum, M;

vector<long long int>sps;

struct aa {
	int fstfinid;
	long long int fstfintime;
	int lasfinid;
	long long int lasfintime;
	int fststaid;
	long long int fststatime;
	int lasstaid;
	long long int lasstatime;
};


long long int check(const vector<vector<bool>>&changes, const vector<vector<long long int>>&times) {
	vector<int>seq(HorseNum);
	iota(seq.begin(), seq.end(), 0);
	aUnionFind uf(HorseNum);
	for (int wide = 0; wide < M; ++wide) {
		for (int change = 0; change < HorseNum - 1; ++change) {
			if (changes[wide][change]) {
				const int c0 = seq[change];
				const int c1 = seq[change + 1];
				const long long int  sa = times[c0][wide] - times[c1][wide];
				if (sa > 0) {
					if (!uf.unionSet(c0, c1, sa)) {
						return My_LInf;
					}
				}
				else {
					return My_LInf;
				}
				swap(seq[change], seq[change + 1]);
			}
		}
	}

	map<int, aa>mp;
	for (int i = 0; i < HorseNum; ++i) {
		if (!mp.count(uf.root(i).first)) {
			mp[uf.root(i).first] = aa{
			i,uf.root(i).second + times[i][M],
			i,uf.root(i).second + times[i][M],
			i,0,
			i,0,
			};
		}
		else {
			if (mp[uf.root(i).first].fstfintime > uf.root(i).second + times[i][M]) {
				mp[uf.root(i).first].fstfinid = i;
				mp[uf.root(i).first].fstfintime = uf.root(i).second + times[i][M];
			}
			if (mp[uf.root(i).first].lasfintime < uf.root(i).second + times[i][M]) {
				mp[uf.root(i).first].lasfinid = i;
				mp[uf.root(i).first].lasfintime = uf.root(i).second + times[i][M];
			}
			mp[uf.root(i).first].lasstaid = i;
			mp[uf.root(i).first].lasstatime = uf.root(i).second;
		}
	}
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		if (it != mp.begin()) {
			aa afrom(prev(it)->second);
			aa ato(it->second);

			if (afrom.lasfintime - afrom.lasstatime>ato.fstfintime-ato.fststatime) {
				uf.unionSet(afrom.lasfinid, ato.fstfinid, times[afrom.lasfinid][M] - times[ato.fstfinid][M]);
			}
			else {
				uf.unionSet(afrom.lasstaid, ato.fststaid, 1);
			}
		}
	}
	for (int i = 0; i < HorseNum - 1; ++i) {
		if (uf.root(i).second >= uf.root(i + 1).second)return My_LInf;
	}
	for (int i = 0; i < HorseNum - 1; ++i) {
		if (uf.root(seq[i]).second+times[seq[i]][M] > uf.root(seq[i + 1]).second + times[seq[i+1]][M])return My_LInf;
	}
	long long int amax = 0;
	for (int i = 0; i <HorseNum; ++i) {
		amax = max(amax, uf.root(i).second + times[i][M] - uf.root(0).second);
	}
	return amax;
}

int main() {
	long long int dist;
	cin >> dist;

	cin >> HorseNum;
	for (int i = 0; i <HorseNum; ++i) {
		int S; cin >> S;
		sps.push_back(S);
	}
	cin >> M;
	vector<long long int>ds;
	for (int i = 0; i < M; ++i) {
		int D; cin >> D;
		ds.push_back(D);
	}
	sort(ds.begin(), ds.end());
	vector<vector<long long int>>times(HorseNum, vector<long long int>(M + 1));
	for (int i = 0; i <HorseNum; ++i) {
		for (int j = 0; j < M; ++j) {
			times[i][j] = sps[i] * ds[j];
		}
		times[i][M] = sps[i] * dist;
	}
	long long int ans = My_LInf;
	for (int i = 0; i < 1<<((HorseNum-1)*M); ++i) {
		bitset<20>bs(i);
		vector<vector<bool>>changes(M, vector<bool>(HorseNum -1));
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			for (int k = 0; k < HorseNum - 1; ++k) {
				changes[j][k] = bs[j*(HorseNum - 1) + k];
			}
		}
		for (int j = 0; j < M; ++j) {
			for (int k = 0; k < HorseNum - 2; ++k) {
				if (changes[j][k] && changes[j][k + 1]) {
					ok = false;
					break;
				}
			}
		}
		if (!ok)continue;
		long long int a = check(changes, times);
		if (a < ans) {
			ans = a;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3176