#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long inf = 1LL << 60;
const double eps = 1e-9;
int main() {
  long long N, tmp;
  cin >> N;
  vector<long long> A(N + 1, 0);
  map<long long, long long> num;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    A[i + 1] = A[i] + tmp;
  }
  sort(A.begin(), A.end());
  tmp = 0;
  long long ans = 0, cnt = 1;
  for (long long i = 1; i < N + 1; i++) {
    if (tmp == A[i])
      cnt++;
    else {
      ans += cnt * (cnt - 1) / long long(2);
      tmp = A[i];
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / long long(2);
  cout << ans << endl;
  return 0;
}
