#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N;
  cin >> N;
  vector<long long> sum(N);
  long long a;
  cin >> a;
  sum.at(0) = a;
  for (long long i = 1; i < N; i++) {
    cin >> a;
    sum.at(i) = sum.at(i - 1) + a;
  }
  sort(sum.begin(), sum.end());
  reverse(sum.begin(), sum.end());
  long long tmp = 1;
  long long ans = 0;
  for (long long i = 1; i < N; i++) {
    if (sum.at(i) == 0) ans++;
    if (sum.at(i) == sum.at(i - 1))
      tmp++;
    else {
      ans += (tmp * (tmp - 1)) / 2;
      tmp = 1;
    }
  }
  ans += (tmp * (tmp - 1)) / 2;
  cout << ans << endl;
}
