#include int main(void) { long long N; long long A[200001]; scanf("%ld", &N); for (int i = 0; i < N; ++i) scanf("%ld", &A[i]); A[N] = 1000000001LL; long long tmp = 1, ans = 0; for (int i = 1; i <= N; ++i) { if (A[i] - A[i - 1] == 1) { tmp++; } else { ans += tmp * (tmp - 1) / 2; tmp = 1; } } printf("%ld\n", ans); return 0; }