#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n), s(n + 1, 0);
  for (auto&& x : a) cin >> x;
  map<long long, int> cnt;
  cnt[s[0]]++;
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + a[i - 1];
    cnt[s[i]]++;
  }
  int ans = 0;
  for (auto&& x : cnt) {
    if (x.second > 1) {
      ans += x.second * (x.second - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
