#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int n,m;
vector<int> a,b;

void solve(){
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	const int INF = INT_MAX/2;
	int ans = INF;
	do{
		auto A = a;
		auto B = b;
		bool ok = true;
		int cnt = 0;
		bool cntis = true;
		for(int i = 0;i<n;i++){
			if(B.empty()){
				ok = false;
				break;
			}else{
				while(B.size()&&B.back()-A[i]<0){
					B.pop_back();
					cntis = true;
				}
				if(B.empty()){
					ok = false;
					break;
				}
				B.back()-= A[i];
				if(cntis)cnt++;
				cntis = false;
			}
		}
		if(ok)
		ans = min(ans,cnt);
	}while(next_permutation(a.begin(),a.end()));
	if(ans==INF)ans=-1;
	cout<<ans<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n;
	a = vector<int>(n);
	for(auto &i:a)cin >> i;
	cin >> m;
	b = vector<int>(m);
	for(auto &i:b)cin >> i;
	solve();
}