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