在[L,R]区域中找到最大值Max,最小值Min,若maxv - minv == j - i,则说明该区域[L,R]是递增且连续的
//
// Created by Genes on 2020/9/13.
//
// 连号区间数
#include<iostream>
#include<climits>
using namespace std;
const int N = 1e4 + 10;
int a[N];
int n;
int res;
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) { //枚举左端点
int Max = INT_MIN, Min = INT_MAX;
for (int j = i; j < n; j++) {
Max = max(Max, a[j]);
Min = min(Min, a[j]);
if(Max-Min==j-i) res++;
}
}
cout<<res<<endl;
return 0;
}