#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, r = 0;
  cin >> N;
  vector<long long> v(N);
  map<long long, int> mp;
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
    if (i > 0) v[i] += v[i - 1];
    mp[v[i]] += 1;
  }
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    if (it->first == 0) r += it->second;
    r += (it->second) * (it->second - 1) / 2;
  }
  cout << r << endl;
}
