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