I,R=input,range N=I() A=list(map(int,I().split())) c=0 L=R(1,2001) for k in L: D=[[0]*4for a in R(4001)] for a in A:D[a]=[D[a][0]+1,D[a][1]+D[a-k-10][0],D[a][2]+D[a+k][1],D[a][3]+D[a-k-1][2]] c+=sum(D[a][3]for a in L) print(c)