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