#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  cin >> n;
  vector<long long> wa(n);
  long ans = 0;
  cin >> wa[0];
  map<long long, int> mp;
  mp[0]++;
  mp[wa[0]]++;
  for (int i = (1); i < (int)(n); i++) {
    long a;
    cin >> a;
    wa[i] = wa[i - 1] + a;
    if (mp[wa[i]]) ans += mp[wa[i]];
    mp[a]++;
  }
  cout << (ans) << endl;
  return 0;
}
