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