#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  vector<long long> sm(N + 2);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    sm[i] = a[i];
  }
  for (int i = 0; i < N; ++i) {
    sm[i + 1] += sm[i];
  }
  sort(sm.begin(), sm.end());
  long long ans = 0ll;
  long long tmp = 1ll;
  for (int i = 1; i <= N; ++i) {
    if (sm[i] != sm[i - 1]) {
      ans += tmp * (tmp - 1) / 2;
      tmp = 0ll;
    }
    tmp++;
  }
  if (tmp > 0) {
    ans += tmp * (tmp - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
