n=int(input()) a=list(map(int,input().split())) b=[a[i+1]-a[i] for i in range(n-1)] q=[] for v in b: if len(q)==0 or q[-1][0]!=v: q+=[[v,0]] q[-1][1]+=1 g=0 for v,c in q: if v==1: g+=(c+1)*c//2 print(g)