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