#include <bits/stdc++.h>
using ll = long long;
ll A[int(1e5) + 100];
int main() {
  int n;
  std::map<ll, int> s;
  std::cin >> n;
  ll cnt = 0;
  ++s[0];
  for (int i = 0; i < n; ++i) {
    std::cin >> A[i + 1];
    A[i + 1] += A[i];
    cnt += s[A[i + 1]];
    ++s[A[i + 1]];
  }
  std::cout << cnt << std::endl;
}
