#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<int> s(n, 0);
  s[0] = a[0];
  map<long long, long long> mp;
  ++mp[s[0]];
  for (int i = 1; i < (n); ++i) {
    s[i] = s[i - 1] + a[i];
    ++mp[s[i]];
  }
  int res = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (itr->first == 0) res += itr->second;
    if (itr->second > 1) res += itr->second * (itr->second - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
