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