#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> sum(N + 1);
  for (int i = 0; i < N; i++) {
    sum[i + 1] = sum[i] + A[i];
  }
  map<long long, int> m;
  for (int i = 0; i < N + 1; i++) {
    m[sum[i]]++;
  }
  long long res = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    pair<long long, int> p = *it;
    if (p.second) {
      res += (p.second * (p.second - 1)) / 2;
    }
  }
  cout << res << endl;
  return 0;
}
