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