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