#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  ll ans = 0, sum = 0;
  multiset<ll> s;
  s.insert(0);
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    sum += A;
    ans += s.count(sum);
    s.insert(sum);
  }
  cout << ans << endl;
  return 0;
}
