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