import sys input = sys.stdin.readline N,M,K=map(int,input().split()) A=list(map(int,input().split())) E=[set() for i in range(N)] for i in range(M): x,y=map(int,input().split()) x-=1 y-=1 E[x].add(y) E[y].add(x) # UnionFind Group = [i for i in range(N)] # グループ分け Nodes = [1]*(N) # 各グループのノードの数 def find(x): while Group[x] != x: x=Group[x] return x def Union(x,y): if find(x) != find(y): if Nodes[find(x)] < Nodes[find(y)]: Nodes[find(y)] += Nodes[find(x)] Nodes[find(x)] = 0 Group[find(x)] = find(y) else: Nodes[find(x)] += Nodes[find(y)] Nodes[find(y)] = 0 Group[find(y)] = find(x) #print(A) SA=[(A[i],i) for i in range(N)] SA.sort() for a,ind in SA: fi=find(ind) NOW=a flag=1 LIST=[] MAX=-1<<60 #print(fi,E[fi]) for to in E[fi]: if find(fi)==find(to): continue if 0<=A[find(to)]-NOW<=K: LIST.append(find(to)) MAX=max(MAX,A[find(to)]) x=fi for to in LIST: Union(x,to) nfi=find(x) if len(E[to])