using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        int N = cin.Int();
        int[] A = cin.ArrayInt(N);

        int[] B = new int[N + 1];
        for (int i = 1; i <= N; i++)
        {
            B[i] = B[i - 1] + A[i - 1];
        }

        var dic = new Dictionary<int, int>();
        dic.Add(0, 1);
        for (int i = 1; i <= N; i++)
        {
            if (dic.ContainsKey(B[i])) dic[B[i]]++;
            else dic.Add(B[i], 1);
        }
        long ans = 0;
        foreach (var x in dic.Values)
        {
            if (x >= 2) ans += x * (x - 1) / 2;
        }

        Console.WriteLine(ans);
        Console.ReadLine();
    }

    static long Combination(int n, int k) //組み合わせ
    {
        long ans = 1;
        for (int i = n; i > n - k; --i)
        {
            ans = ans * i;
        }
        for (int i = 1; i < k + 1; ++i)
        {
            ans = ans / i;
        }
        return ans;
    }


}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}
