1 #include<cstdio>
2 #include<iostream>
3 #include<cmath>
4 #include<queue>
5
6 using namespace std;
7
8 priority_queue<int> q1;
9 priority_queue<int> q2;
10
11 int n, m, b[100005], g[100005], cnt;
12
13 int main(){
14 scanf("%d", &n);
15 for(int i = 1; i <= n; i++){
16 scanf("%d", &b[i]);
17 q1.push(-b[i]);
18 }
19 scanf("%d", &m);
20 for(int i = 1; i <= m; i++){
21 scanf("%d", &g[i]);
22 q2.push(-g[i]);
23 }
24 while(!q1.empty() && !q2.empty()){
25 int t1 = -q1.top();
26 int t2 = -q2.top();
27 if(abs(t1 - t2) <= 1){
28 cnt++;
29 q1.pop();
30 q2.pop();
31 }
32 else{
33 if(t1 < t2) q1.pop();
34 else q2.pop();
35 }
36 }
37 printf("%d
", cnt);
38 return 0;
39 }