def main(): # 入力 n = int(raw_input()) a = list(map(int, raw_input().split())) assert 1 <= n <= 150000 minA = min(a) maxA = max(a) assert 1 <= minA <= 100 and maxA <= 100 # raの初期化 ra = [0] * (n + 1) ans = n * (n + 1) // 2 for x in range(minA, maxA + 1): ra[0] = 0 for i in range(n): ra[i + 1] = ra[i] + a[i] - x # 隣接重複を削除 rb = [ra[0]] for i in range(1, len(ra)): if ra[i] != ra[i - 1]: rb.append(ra[i]) # raをソート ra.sort() # rbをソート rb.sort() # raに基づいてカウント cnt = 0 for i in range(n + 1): if i > 0 and ra[i] != ra[i - 1]: ans -= cnt * (cnt - 1) // 2 cnt = 0 cnt += 1 ans -= cnt * (cnt - 1) // 2 # rbに基づいてカウント cnt = 0 for i in range(len(rb)): if i > 0 and rb[i] != rb[i - 1]: ans += cnt * (cnt - 1) // 2 cnt = 0 cnt += 1 ans += cnt * (cnt - 1) // 2 ans += 1 # 初期状態の分を足す print(ans) if __name__ == "__main__": main()