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