#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> A(n);
  for (int i = 0; i < n; ++i) cin >> A[i];
  vector<long long> A_sum(n);
  A_sum[0] = A[0];
  for (int i = 0; i < n - 1; ++i) {
    A_sum[i + 1] = A_sum[i] + A[i + 1];
  }
  sort(A_sum.begin(), A_sum.end());
  long long ans = 0;
  for (int i = 0; i < n; ++i)
    if (A_sum[i] == 0) ans++;
  for (int i = 0; i < n - 1; ++i) {
    long long l = 1;
    while (A_sum[i] == A_sum[i + 1]) {
      i++;
      l++;
    }
    ans += l * (l - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
