#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long A[N];
  for (int i = 0; i < N; ++i) cin >> A[i];
  long long count = 0;
  long long sum[N];
  sum[0] = A[0];
  for (int i = 1; i < N; ++i) {
    sum[i] = A[i] + sum[i - 1];
    if (sum[i] == 0) ++count;
  }
  long long group[N];
  for (int i = 0; i < N; ++i) {
    group[i] = 1;
  }
  sort(sum, sum + N);
  int j = 0;
  for (int i = 1; i < N; ++i) {
    if (sum[i] == sum[i - 1])
      ++group[j];
    else
      ++j;
  }
  long long count2 = 1;
  long long k;
  for (int i = 0; i < N; ++i) {
    if (group[i] >= 2) {
      k = group[i];
      count += k * (k - 1) / 2;
    }
  }
  cout << count;
  return 0;
}
