#include using namespace std; int main() { int64_t n; cin >> n; vector a(n); for(int64_t i = 0; i < n; i++) cin >> a[i]; int64_t v = a[0]; int64_t ans = 0; int64_t cnt = 1; for(int64_t i = 1; i < n; i++) { if(v + 1 == a[i]) cnt++; else { ans += cnt * (cnt - 1) / 2; cnt = 1; } v = a[i]; } ans += cnt * (cnt - 1) / 2; cout << ans << endl; return 0; }