from bisect import bisect_left,bisect_right n = int(input()) a = list(map(int,input().split())) b = [[] for _ in range(2001)] for i,v in enumerate(a): b[v].append(i) ans = 0 for i in range(n-1): for j in range(i+1,n): p = a[j]-10; q = a[i]+1; k = a[i]-p-10 if 1<=p<=2000>=q>=1<=k: ans += bisect_left(b[p],i)*(len(b[q])-bisect_right(b[q],j)) print(ans)