/* -*- coding: utf-8 -*- * * 2053.cc: No.2053 12345... - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N]; /* subroutines */ inline ll nc2(int n) { return (ll)n * (n - 1) / 2; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); ll sum = 0; for (int i = 0; i < n;) { int j = i + 1; while (j < n && as[j - 1] + 1 == as[j]) j++; sum += nc2(j - i); i = j; } printf("%lld\n", sum); return 0; }