label 1,2,3;
var i,k,n,j,p,s:longint;a,v:array[1..1000000] of longint;
q,w:text;
begin
assign(q,'punctfix.in');
reset(q);
assign(w,'punctfix.out');
rewrite(w);
readln(q,n);
if (n<2)and(n>10000) then goto 3;
for i:=1 to n do begin
read(q,a[i]);
end;
readln(q,k);
if (k<1)and(n>15000) then goto 3;
for i:=1 to k do begin
read(q,v[i]);
end;
for i:=1 to n-1 do begin
if a[i]>a[i+1] then goto 3;end;
if (a[n]-a[1])>100000 then goto 3;
if (v[n]-v[1])>100000 then goto 3;
for i:=1 to k do begin
for j:=1 to n do begin
s:=a[j]+v[i];
if s=j then p:=p+1;s:=0;
end;
writeln(w,p);p:=0;end;
3:close(q);
close(w);
end.