#include <bits/stdc++.h>
using namespace std;
long long INF = 1e9 + 7;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, 1, 0, -1};
signed main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> cnt(N + 1);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    cnt[i + 1] += A[i];
  }
  for (long long i = 0; i < N; i++) {
    cnt[i + 1] += cnt[i];
  }
  sort(cnt.begin(), cnt.end());
  long long ans = 0;
  long long sum = 1;
  for (long long i = 1; i <= N; i++) {
    if (cnt[i] == cnt[i - 1]) {
      sum++;
    } else {
      ans += (sum * (sum - 1)) / 2;
      sum = 1;
    }
  }
  if (sum != 1) {
    ans += (sum + (sum - 1)) / 2;
  }
  cout << ans << endl;
}
