#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int n; cin>>n; vector a(n); rep(i,n){ cin>>a[i]; } vector C; rep(i,n){ if(C.size()!=0 && a[i]==a[i-1]+1)C.back()++; else C.push_back(1); } long long ans = 0; rep(i,C.size()){ ans += C[i] * (C[i]+1) / 2; } ans -= n; cout<