#include <bits/stdc++.h>
int main(void) {
  using namespace std;
  int N;
  cin >> N;
  vector<long long> sum(N + 1);
  sum[0] = 0;
  for (int i = 1; i < N + 1; i++) {
    long a;
    cin >> a;
    sum[i] = a + sum[i - 1];
  }
  sort(sum.begin(), sum.end());
  long long now_sum = sum[0];
  int num = 1;
  long res = 0;
  for (int i = 1; i < N + 1; i++) {
    if (now_sum == sum[i])
      num++;
    else {
      res += (num - 1) * num / 2;
      num = 1;
      now_sum = sum[i];
    }
  }
  if (now_sum != sum[0]) {
    res += (num - 1) * num / 2;
  }
  cout << res << endl;
  return 0;
}
