#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  int n, count = 0;
  cin >> n;
  vector<int> v(n);
  vector<int> v2(n);
  for (auto& i : v) {
    cin >> i;
  }
  int tmp = 0;
  for (size_t j = 0; j < n; j++) {
    tmp += *(v.begin() + j);
    v2[j] = tmp;
    if (tmp == 0) {
      count++;
    }
  }
  for (size_t i = 1; i < n; i++) {
    for (size_t j = 0; j < n - i; j++) {
      if (v2[j + i] - v2[i - 1] == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}
