#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<ll> sum(N + 1);
  sum[0] = 0;
  for (int i = 1; i < N + 1; i++) {
    sum[i] += sum[i - 1] + A[i - 1];
  }
  sort(sum.begin(), sum.end());
  ll ans = 0;
  for (int i = 0; i <= N; i++) {
    int num = 0;
    while (i < N && sum[i] == sum[i + 1]) {
      num++;
      i++;
    }
    if (num == 0)
      continue;
    else if (num == 1)
      ans++;
    else
      ans += num * (num - 1);
  }
  cout << ans << endl;
  return 0;
}
