using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static long[] ReadLongArray()
    {
        return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        long[] a = ReadLongArray();

        long[] b = new long[n+1];
        for (int i = 1; i <= n; i++)
            b[i] = b[i-1] + a[i-1];

        long ans = 0;
        for (int i = 0; i < n; i++)
            for (int j = i+1; j <= n; j++)
                if (b[j] - b[i] == 0) ans++;

        WriteLine(ans);
    }
}