from collections import defaultdict n = int(input()) a = list(map(int, input().split(' '))) m = max(a) ans = 0 for i in range(n): buf = [0] * (m+2) left_buf = defaultdict(int) for j in range(i, n): buf[a[j]] += 1 for j in range(i, n): if a[j] == a[i] + 10: for key, val in left_buf.items(): estimate = key - a[i] - 10 if estimate > 0: ans += val * buf[key+1] buf[a[j]] -= 1 left_buf[a[j]] += 1 print(ans)