#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<long> S(N);
  S.at(0) = A.at(0);
  for (int i = 1; i < N; i++) {
    S.at(i) = S.at(i - 1) + A.at(i);
  }
  sort(S.begin(), S.end());
  int ans = 0, count;
  if (S.at(0) == 0) {
    count = 0;
  } else {
    count = 1;
  }
  long prev = 0, now;
  for (int i = 0; i < N; i++) {
    now = S.at(i);
    if (now == 0) ans++;
    if (prev == now) {
      count++;
    } else {
      ans += count * (count - 1) / 2;
      count = 1;
    }
    prev = now;
  }
  ans += count * (count - 1) / 2;
  cout << ans << endl;
}
