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