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