#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i{}; i < N; ++i) cin >> A[i];
  vector<ll> s(N + 1, 0);
  for (int i{}; i < N; ++i) {
    s[i + 1] = s[i] + A[i];
  }
  map<ll, int> num;
  for (int i{}; i <= N; ++i) {
    ++num[s[i]];
  }
  ll ans{};
  for (const auto &p : num) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}
