n = int(input()) a = list(map(int, input().split())) odd = [] even = [] for i in range(n): if a[i] % 2 == 1: odd.append(a[i]) else: even.append(a[i]) odd = sorted(odd) even = sorted(even) odd.append(1e18 - 1) even.append(1e18) oddacc = [1] * len(odd) for i in range(1, len(odd)): j = len(odd) - i - 1 if odd[j] + 2 == odd[j + 1]: oddacc[j] += oddacc[j + 1] evenacc = [1] * len(even) for i in range(1, len(even)): j = len(even) - i - 1 if even[j] + 2 == even[j + 1]: evenacc[j] += evenacc[j + 1] ans = n it = 0 for i in range(len(odd) - 1): while odd[i] >= even[it]: it += 1 if odd[i] + 1 == even[it]: ans += evenacc[it] it = 0 for i in range(len(even) - 1): while even[i] >= odd[it]: it += 1 if even[i] + 1 == odd[it]: ans += oddacc[it] print(ans)