n = int(input()) a = list(map(int,input().split())) m = max(a); s = n*(n-1)//2+1 for i in range(1,m+1): b = [0]; d = {} for v in a: b.append(b[-1]+v-i) for i,v in enumerate(b): if v in d and d[v][-1]==i-1: s -= len(d[v])-1; d[v].append(i) else: d[v] = [i] print(s)