N=int(input()) A=list(map(int, input().split())) aa=max(A)+10;ans=0 for k in range(1,max(A)+1): dp1=[0]*aa;dp2=[0]*aa;dp3=[0]*aa;dp4=[0]*aa x,y,z=k+1,-k,k+10 for a in A: if aa>a-x>0: dp4[a]+=dp3[a-x] if aa>a-y>0: dp3[a]+=dp2[a-y] if aa>a-z>0: dp2[a]+=dp1[a-z] dp1[a]+=1 ans+=sum(dp4) print(ans)