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