1 #include <iostream>
2 #include <cstdio>
3 #include <algorithm>
4 #include <cstring>
5 #include <cmath>
6 #define rep(i,l,r) for(int i=l; i<=r; i++)
7 #define clr(x,y) memset(x,y,sizeof(x))
8 #define travel(x) for(Edge *p=last[x]; p; p=p->pre)
9 using namespace std;
10 const int INF = 0x3f3f3f3f;
11 const int maxn = 1010;
12 inline int read(){
13 int ans = 0, f = 1;
14 char c = getchar();
15 for(; !isdigit(c); c = getchar())
16 if (c == ‘-‘) f = -1;
17 for(; isdigit(c); c = getchar())
18 ans = ans * 10 + c - ‘0‘;
19 return ans * f;
20 }
21 struct Edge{
22 int from,to;
23 double cost;
24 inline bool operator < (const Edge &_Tp) const{
25 return cost < _Tp.cost;
26 }
27 }edge[500010];
28 struct Point{
29 int x,y;
30 }t[maxn];
31 int n,m,cnt=0,h[maxn],fa[maxn];
32 inline double getdis(Point a,Point b){
33 return sqrt((a.x-b.x) * (a.x-b.x) + (a.y-b.y) * (a.y-b.y));
34 }
35 inline void addedge(int x,int y,double dis){
36 edge[++cnt].from = x; edge[cnt].to = y; edge[cnt].cost = dis;
37 }
38 int getfa(int x){
39 return fa[x] == x ? x : fa[x] = getfa(fa[x]);
40 }
41 int main(){
42 m = read();
43 rep(i,1,m) h[i] = read();
44 n = read();
45 rep(i,1,n) t[i].x = read(), t[i].y = read();
46 rep(i,1,n-1) rep(j,i+1,n) addedge(i,j,getdis(t[i],t[j]));
47 sort(edge+1,edge+cnt+1);
48 rep(i,1,n) fa[i] = i;
49 double mx = -INF;
50 rep(i,1,cnt){
51 int a = getfa(edge[i].from);
52 int b = getfa(edge[i].to);
53 if (a != b){
54 fa[a] = b;
55 mx = max(mx,edge[i].cost);
56 }
57 }
58 int ans = 0; rep(i,1,m) if (h[i] >= mx) ans++;
59 printf("%d\n",ans);
60 return 0;
61 }