#include using namespace std; int main(){ int N, A, prev; long long count = 0, ans = 0; cin >> N; for(int i = 0; i < N; i++){ cin >> A; if(i == 0 || prev + 1 == A){ ++count; }else{ ans += (count - 1) * count / 2; count = 1; } prev = A; } ans += (count - 1) * count / 2; cout << ans << endl; }