#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long ary[n];
  for (int i = (int)(0); i < (int)(n); ++i) cin >> ary[i];
  long long ruisekiwa[n + 1];
  ruisekiwa[0] = 0;
  map<long long, int> mp;
  mp[0] = 1;
  for (int i = (int)(0); i < (int)(n); ++i) {
    ruisekiwa[i + 1] = ruisekiwa[i] + ary[i];
    auto tmp_iter = mp.find(ruisekiwa[i + 1]);
    if (tmp_iter == mp.end()) {
      mp[ruisekiwa[i + 1]] = 1;
    } else {
      mp[ruisekiwa[i + 1]]++;
    }
  }
  long long ans = 0;
  for (auto iter = mp.begin(); iter != mp.end(); iter++) {
    ans += iter->second * (iter->second - 1) / 2;
  }
  cout << ans << endl;
}
