# your code goes here
n=int(input())
arr=list(map(int, input().split()))
tg=int(input())
mp={}
ctr=0
for x in arr:
	r1=x+tg
	r2=x-tg
	if tg==0:
		ctr+=mp.get(r1, 0)
	else:
		ctr+=mp.get(r1, 0)
		ctr+=mp.get(r2, 0)
	mp[x]=mp.get(x, 0)+1
print(ctr)