import java.util.*;
class Main{
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int n=in.nextInt();
int a[]=new int [n+1];
for(int i=1;i<=n;i) {
a[i]=in.nextInt();
}
int ans=0;
for(int i=1;i<=n;i) {
int max=a[i];
int min=a[i];
for(int j=i;j<=n;j) {
if(a[j]>max) {
max=a[j];
}
if(a[j]<min) {
min=a[j];
}
if(i==j) {
ans;
}else {
int cnt=j-i;
if(max-min==cnt) {
ans++;
}
}
}
}
System.out.println(ans);
}
}