#include <bits/stdc++.h>
using namespace std;
long long int ncr(long long int n, long long int r) {
  long long int i, ans;
  ans = 1;
  for (i = 1; i <= (n - r); i++) {
    ans *= (n - i + 1);
    ans /= i;
  }
  return ans;
}
int main(void) {
  int n;
  vector<long long int> a;
  long long int t, sum, res;
  cin >> n;
  sum = res = 0;
  map<long long int, long long int> mp;
  mp[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> t;
    sum += t;
    a.push_back(t);
    if (mp.count(sum) == 0)
      mp[sum] = 1;
    else
      mp[sum] = mp[sum] + 1;
  }
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (itr->second <= 1) continue;
    res += ncr(itr->second, 2);
  }
  cout << res << endl;
  return 0;
}
