N = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(N - 3): for j in range(i + 1, N - 2): for k in range(j + 1, N - 1): for l in range(k + 1, N): if ( A[i] + 10 == A[k] and A[j] + 1 == A[l] and A[i] < A[j] and A[j] > A[k] and A[k] < A[l] ): ans += 1 print(ans)