#include<iostream>#include<cstring>#include<algorithm>#include<string>usingnamespace std;int a[100001], b[100001];};boolcmp(int a,int b){return a > b;}intmain(){int n; cin >> n;for(int i =0; i < n; i++){
cin >> a[i];}int m; cin >> m;for(int i =0; i < m; i++){
cin >> b[i];}sort(a, a + n, cmp);sort(b, b + n, cmp);int i =0, j, sum =0;while(i < n && i < m && a[i]>0&& b[i]>0){
sum += a[i]* b[i];
i++;}
i = n -1;
j = m -1;while(i >=0&& j >=0&&a[i]<0&&b[j]<0){
sum += a[i]* b[i];
i--;
j--;}
cout << sum;}