def make_sumlist(n,a):
    cnt = 0
    sum_list = []
    for start in range(n-1):
        for last in range(start+2,n+1):
            new_sum = sum(a[start:last])
            sum_list.append(new_sum)
            if new_sum == 0:
                cnt += 1

    return cnt

def main():
    # 1.input
    n = int(input())
    a = list(map(int, input().split()))
    numofZero = make_sumlist(n,a)
    print(numofZero)


if __name__ == "__main__":
    main()