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