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