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