1 /**************************************************************
2 Problem: 2429
3 User: HansBug
4 Language: Pascal
5 Result: Accepted
6 Time:396 ms
7 Memory:11976 kb
8 ****************************************************************/
9
10 var
11 i,j,k,l,m,n,mm:longint;
12 b:array[0..2000,1..2] of longint;
13 a:array[0..1000005,1..3] of longint;
14 c,d:array[0..2000] of longint;
15 function max(x,y:longint):longint;inline;
16 begin
17 if x>y then max:=x else max:=y;
18 end;
19 procedure swap(var x,y:longint);inline;
20 var z:longint;
21 begin
22 z:=x;x:=y;y:=z;
23 end;
24 procedure sort(l,r:longint);inline;
25 var i,j,x,y:longint;
26 begin
27 i:=l;j:=r;x:=a[(l+r) div 2,3];
28 repeat
29 while a[i,3]<x do inc(i);
30 while a[j,3]>x do dec(j);
31 if i<=j then
32 begin
33 swap(a[i,1],a[j,1]);
34 swap(a[i,2],a[j,2]);
35 swap(a[i,3],a[j,3]);
36 inc(i);dec(j);
37 end;
38 until i>j;
39 if i<r then sort(i,r);
40 if l<j then sort(l,j);
41 end;
42 function getfat(x:longint):longint;inline;
43 begin
44 if x<>c[x] then c[x]:=getfat(c[x]);
45 exit(c[x]);
46 end;
47 begin
48 readln(m);
49 for i:=1 to m do read(d[i]);
50 readln;l:=0;readln(n);
51 for i:=1 to n do readln(b[i,1],b[i,2]);
52 for i:=1 to n-1 do
53 for j:=i+1 to n do
54 begin
55 inc(l);a[l,1]:=i;a[l,2]:=j;
56 a[l,3]:=(b[i,1]-b[j,1])*(b[i,1]-b[j,1])+(b[i,2]-b[j,2])*(b[i,2]-b[j,2]);
57 end;
58 sort(1,l);
59 for i:=1 to n do c[i]:=i;
60 j:=0;mm:=0;
61 for i:=1 to n-1 do
62 begin
63 repeat
64 inc(j);
65 k:=getfat(a[j,1]);
66 l:=getfat(a[j,2]);
67 until k<>l;
68 mm:=max(mm,a[j,3]);
69 c[k]:=l;
70 end;
71 l:=0;
72 for i:=1 to m do if (d[i]*d[i])>=mm then inc(L);
73 writeln(l);
74 readln;
75 end.