#include using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; int A[200010] = {}; for(int i = 0; i < N; i++) cin >> A[i]; long long ans = 0; long long left = 0; for(long long i = 1; i <= N; i++){ if(A[i] == A[i-1] + 1) continue; ans += (i - left) * (i - left - 1) / 2; left = i; } cout << ans << "\n"; }