#include <bits/stdc++.h>
using namespace std;
long long A[200000];
long long cum_sum[200001];
map<long long, int> cum_sum_count;
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  cum_sum[0] = 0;
  for (int i = 0; i < N; i++) {
    cum_sum[i + 1] = A[i] + cum_sum[i];
  }
  for (int i = 0; i < N + 1; i++) {
    if (cum_sum_count.find(cum_sum[i]) == cum_sum_count.end()) {
      cum_sum_count[cum_sum[i]] = 1;
    } else {
      cum_sum_count[cum_sum[i]]++;
    }
  }
  long long ans = 0;
  for (auto it = cum_sum_count.begin(); it != cum_sum_count.end(); it++) {
    ans += it->second * (it->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
