using System;
using System.Linq;
using System.Collections.Generic;
public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine());
    long[] A = new[]{ 0L }.Concat(Console.ReadLine().Split(' ').Select(long.Parse)).ToArray();
    for (int i = 2; i < N+1; i++) {
      A[i] = A[i-1] + A[i];
    }

    Dictionary<long, int> dic = new Dictionary<long, int>();
    foreach (long l in A) {
      if (!dic.ContainsKey(l)) {
        dic[l] = 1;
      } else {
        dic[l] += 1;
      }
    }

    int count = 0;
    foreach (int i in dic.Values) {
      count += i * (i-1) / 2;
    }
    Console.WriteLine(count);
  }
}
