#include <bits/stdc++.h>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
int N, x, ans, sigma;
int a[200000];
multiset<int> s;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    sigma += a[i];
    if (sigma == 0) {
      ans++;
    }
    s.insert(sigma);
  }
  while (!s.empty()) {
    set<int>::iterator i = s.begin();
    size_t n = s.count(*i);
    if (n >= 2) {
      ans += n * (n - 1) / 2;
    }
    s.erase(*i);
  }
  cout << ans << endl;
  return 0;
}
