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