#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (long long(i) = 0; (i) < (long long)(n); ++(i)) cin >> a[i];
  map<long long, int> mp;
  mp[0] = 1;
  long long tmp = 0;
  for (long long(i) = 0; (i) < (long long)(n); ++(i)) {
    tmp += a[i];
    mp[tmp]++;
  }
  long long ans = 0;
  for (auto x : mp) {
    if (mp[x.first] == 0) continue;
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
