#include <iostream>
#include <algorithm>
using namespace std;
const int N = 60 , M = 1e3 + 10;
int n , m , ans , a[N] , b[M];
void dfs(int x,int y,int len)
{
if(y > n || x > m) return ;
if(len < b[x]) dfs(x , y + 1 , len + a[y + 1]);
else {
ans ++;
dfs(x + 1 , y , len - b[x]);
}
return ;
}
int main()
{
cin >> n;
for(int i = 1; i <= n ; ++i) cin >> a[i];
cin >> m;
for(int i = 1 ; i <= m ; ++i) cin >> b[i];
sort(a + 1 , a + n + 1);
sort(b + 1 , b + m + 1);
dfs(1 , 1 , a[1]);
cout << ans << endl;
return 0;
}