if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    dp = [[0] * n for _ in range(n)]

    dp[0] = a
    ans = 0
    for i in range(1, n):
        for j in range(n-i):
            dp[i][j] = dp[i-1][j] + a[i+j]
            if dp[i][j] == 0:
                ans += 1

    print(ans)
