#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<long long> Q(N);
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
    if (i) Q[i] += Q[i - 1];
  }
  Q.push_back(0);
  sort(Q.begin(), Q.end());
  long long cnt = 0, cp = 0;
  for (int i = 0; i < N + 1; i++) {
    cp++;
    if (i == N && Q[i] == Q[i + 1]) {
    } else {
      cnt += cp * (cp - 1) / 2;
      cp = 0;
    }
  }
  cout << cnt;
}
