def II(): return int(input()) def MI(): return map(int, input().split()) def TI(): return tuple(MI()) def LI(): return list(MI()) #str-input def SI(): return input() def MSI(): return input().split() def SI_L(): return list(SI()) def SI_LI(): return list(map(int, SI())) #multiple-input def LLI(n): return [LI() for _ in range(n)] def LSI(n): return [SI() for _ in range(n)] #1-indexを0-indexでinput def MI_1(): return map(lambda x:int(x)-1, input().split()) def TI_1(): return tuple(MI_1()) def LI_1(): return list(MI_1()) class fenwick_tree(): n=1 data=[0 for i in range(n)] def __init__(self,N): self.n=N self.data=[0 for i in range(N)] def add(self,p,x): assert 0<=p0): s+=self.data[r-1] r-=r&-r return s class dsu(): n=1 parent_or_size=[-1 for i in range(n)] def __init__(self,N): self.n=N self.parent_or_size=[-1 for i in range(N)] def merge(self,a,b): assert 0<=a0: result2.append(result[i]) return result2 def lis(l): #最長増加部分列 n = len(l) tmp = [] # いまi文字目に使える最小 idxlist = [None] * n # l[i]が使われた場所 for i in range(n): numidx = bisect_right(tmp, l[i]) if numidx == len(tmp): tmp.append(l[i]) else: tmp[numidx] = l[i] idxlist[i] = numidx # LIS復元 look = len(tmp) - 1 ans = [0] * (look + 1) idx = [0] * (look + 1) # 後ろから見ていく for i in range(n-1,-1,-1): if idxlist[i] == look: ans[look] = l[i] # ansを確定 idx[look] = i look -= 1 return ans,idx from bisect import bisect_left,bisect_right from heapq import heapify,heappop,heappush,heappushpop,merge from collections import deque,defaultdict,Counter inf = 1<<60 mod = 10**9+7 n = II() a = LI() ans = n*(n+1)//2 + 1 + n for ave in range(1,30): #コレだけの差があるよ b = [i-ave for i in a] cnt = defaultdict(int) cnt[0] = 1 s = 0 for i in range(n): s += b[i] cnt[s] += 1 if b[i] == 0: ans -= cnt[s] # print(cnt,ave) # print(ave,cnt) print(ans)