#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
signed main() {
  long long n;
  cin >> n;
  vector<long long> A(n);
  for (long long i = 0; i < n; i++) cin >> A[i];
  vector<long long> S(n + 1);
  S[0] = 0;
  for (long long i = 1; i < n + 1; i++) {
    S[i] = S[i - 1] + A[i - 1];
  }
  sort(S.begin(), S.end());
  long long ans = 0;
  long long count = 1;
  for (long long i = 0; i < n + 1; i++) {
    if (S[i] == S[i + 1])
      count++;
    else {
      ans += count * (count - 1) / 2;
      count = 1;
    }
  }
  cout << ans << endl;
}
