#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9 + 7;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using MIte = multimap<long, long, greater<long> >::iterator;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long N;
  cin >> N;
  vector<int> vA(N, 0);
  vector<int> vSum(N, 0);
  for (int i = (int)(0); i < (int)(N); ++i) cin >> vA[i];
  vSum[0] = vA[0];
  for (int i = (int)(0); i < (int)(N - 1); ++i) {
    vSum[i + 1] = vSum[i] + vA[i + 1];
  }
  map<int, ll> mnum;
  for (int i = (int)(0); i < (int)(N); ++i) {
    map<int, ll>::iterator it = mnum.find(vSum[i]);
    if (it == mnum.end()) {
      mnum.insert(make_pair(vSum[i], 1));
    } else {
      it->second++;
    }
  }
  long long ans = 0;
  for (map<int, ll>::iterator it = mnum.begin(); it != mnum.end(); ++it) {
    if (it->first == 0) {
      ans += (it->second + 1) * it->second / 2;
    } else {
      ans += (it->second) * (it->second - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
