#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> sum(n, 0);
  int count = 0;
  cin >> a[0];
  sum[0] = a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 0; i < n; i++) {
    if (!sum[i]) count++;
  }
  for (int i = 1; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (sum[j] == sum[i - 1]) count++;
    }
  }
  cout << count << endl;
}
