#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  long long sum[200001];
  cin >> N;
  sum[0] = 0;
  long long a[200001];
  long long cnt = 0;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    sum[i] = (sum[i - 1] + a[i]);
    if (sum[i] == 0) {
      cnt++;
    }
  }
  sort(sum + 1, sum + N + 1);
  int temp = 1;
  for (int i = 1; i < N; i++) {
    if (sum[i] != sum[i + 1]) {
      if (temp >= 2) {
        cnt += ((temp - 1) * (1 + temp - 1) / 2);
      }
      temp = 1;
    } else {
      temp++;
    }
  }
  if (temp >= 2) {
    cnt += ((temp - 1) * (1 + temp - 1) / 2);
  }
  cout << cnt << '\n';
  return 0;
}
