#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> S(N + 1, 0);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    S[i + 1] = S[i] + A[i];
  }
  sort(S.begin(), S.end());
  unordered_map<int, int> m;
  for (auto e : S) m[e]++;
  long long ans = 0;
  for (auto p : m) {
    if (p.second > 1) {
      ans += p.second * (p.second - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
