#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, a[300000], count = 0, m = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    m = a[i];
    for (int k = i + 1; k < N; k++) {
      m = m + a[k];
      if (m == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
