#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long A[N + 1];
  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> A[i];
  A[0] = 0;
  long long B[N + 1];
  long long sum = 0;
  for (int i = 0; i <= N; ++i) {
    sum += A[i];
    B[i] = sum;
  }
  sort(B, B + N + 1);
  int counter = 0, ptr = 0;
  while (ptr <= N) {
    long long cc = B[ptr];
    int f = 0;
    while (ptr <= N && B[ptr] == cc) {
      ++ptr;
      ++f;
    }
    counter += f * (f - 1) / 2;
  }
  cout << counter << endl;
}
