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