import numpy as np def main(): n = int(input()) a = list(map(int, input().split())) M = 100 R = n * M # numpyでゼロ初期化されたint型配列を作成 cnt_zero = np.zeros(2 * R + 1, dtype=np.int_) cnt_non_zero = np.zeros(2 * R + 1, dtype=np.int_) ans = n * (n + 1) // 2 for x in range(1, M + 1): b = [a[i] - x for i in range(n)] s = [0] * (n + 1) for i in range(n): s[i + 1] = s[i] + b[i] for i in range(n): if b[i] == 0: cnt_zero[R + s[i]] += 1 ans -= cnt_zero[R + s[i + 1]] + cnt_non_zero[R + s[i + 1]] else: cnt_non_zero[R + s[i]] += 1 ans -= cnt_zero[R + s[i + 1]] for i in range(n): if b[i] == 0: cnt_zero[R + s[i]] = 0 else: cnt_non_zero[R + s[i]] = 0 ans += 1 print(ans) if __name__ == "__main__": main()