N = int(input()) A = list(map(int, input().split())) maxa = max(A) dp = [[0] * (maxa + 1) for _ in range(N + 1)] dp[0][0] = 1 ans = 0 for k in range(1, maxa): dp = [[0] * (maxa + 1) for _ in range(N + 1)] dp[0][0] = 1 for a in A: dp[1][a] += dp[0][0] if 0 < a - k - 10 <= maxa: dp[2][a] += dp[1][a - k - 10] if 0 < a + k <= maxa: dp[3][a] += dp[2][a + k] if 0 < a - k - 1 <= maxa: dp[4][a] += dp[3][a - k - 1] ans += sum(dp[4]) print(ans)