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