#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[200005];
  long long int sums[200005];
  map<long long int, int> seen;
  cin >> a[0];
  sums[0] = a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    sums[i] = sums[i - 1] + a[i];
  }
  seen[0] = 1;
  int count = 0;
  for (int i = 0; i < n; i++) {
    count += seen[sums[i]];
    seen[sums[i]]++;
  }
  cout << count;
}
