#include <bits/stdc++.h>
using namespace std;
unsigned long long num[100006];
map<unsigned long long, unsigned long long> my;
int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> num[i];
  my[0] = 1;
  unsigned long long sum = 0;
  unsigned long long ask = 0;
  for (int i = 1; i <= n; i++) {
    sum += num[i];
    if (my.count(sum)) ask += my[sum];
    my[sum]++;
  }
  cout << ask << endl;
  return 0;
}
