#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
long long nums[200009];
long long m;
map<long long, long long> mp;
int main() {
  int n;
  int ans = 0;
  while (~scanf("%d", &n)) {
    mp.clear();
    long long all = 0;
    for (int i = 0; i < n; i++) {
      scanf("%lld", &m);
      all += m;
      mp[all]++;
    }
    long long res = 0;
    mp[res]++;
    for (auto it : mp) {
      res += (it.second >> 1) * (it.second - 1);
    }
    printf("%lld\n", res);
  }
  return 0;
}
