# your code goes here
n=int(input())
A=list(map(int,input().split()))
target=int(input())
counter=0
mp={}
for j in range(n):
    r1=A[j]+target
    r2=A[j]-target
    if target==0:
        counter+=mp.get(r1,0)
    else:
        counter+=mp.get(r1,0)
        counter+=mp.get(r2,0)
    mp[A[j]]=mp.get(A[j],0)+1
print(counter)