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