#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
long long m;
int main() {
  int n;
  while (cin >> n) {
    long long all = 0;
    map<long long, long long> mp;
    for (int i = 0; i < n; i++) {
      cin >> m;
      all += m;
      mp[all]++;
    }
    long long res = 0;
    mp[res]++;
    map<long long, long long>::iterator it;
    for (it = mp.begin(); it != mp.end(); it++) {
      res += (it->second >> 1) * (it->second - 1);
    }
    cout << res << endl;
  }
  return 0;
}
