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