#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  long long int a[N];
  long long int b[N + 1];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  fill(b, b + N + 1, 0);
  for (int i = 1; i <= N; i++) {
    b[i] = b[i - 1] + a[i - 1];
  }
  int cnt = 0;
  sort(b, b + N + 1);
  map<long long int, int> x;
  for (int i = 0; i <= N; i++) {
    x[b[i]]++;
  }
  for (map<long long int, int>::iterator y = x.begin(); y != x.end(); ++y) {
    cnt += y->second * (y->second - 1) / 2;
  }
  cout << cnt << endl;
  return 0;
}
