#include <bits/stdc++.h>
using namespace std;
long long num_seq[200005];
int main() {
  long long N, idx = 0, count = 0, sum_num = 0, target;
  cin >> N;
  num_seq[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> num_seq[i];
    num_seq[i] += num_seq[i - 1];
  }
  sort(num_seq, num_seq + N + 1);
  for (int i = 0; i <= N; i++) {
    target = num_seq[i];
    sum_num++;
    if (num_seq[i + 1] != target) {
      count += long long((sum_num * (sum_num - 1)) / 2);
      sum_num = 0;
    }
  }
  cout << count << endl;
  return 0;
}
