#include <bits/stdc++.h>
const int INF = 1001001001;
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  vector<int> d(N + 1);
  map<int, int> mp;
  d[0] = 0;
  for (int i = 0; i < N; i++) {
    d[i + 1] = d[i] + a[i];
    auto it = mp.find(d[i + 1]);
    if (it != mp.end())
      it->second++;
    else {
      mp.insert(make_pair(d[i + 1], 1));
    }
  }
  long long res = 0;
  if (mp.size()) {
    auto it = mp.find(0);
    if (it != mp.end()) res += it->second;
    for (auto it : mp) {
      res += it.second * (it.second - 1) / 2;
    }
  }
  cout << res << endl;
}
