#include <bits/stdc++.h>
int main() {
  int a, n, m, i, s, c;
  c = 0;
  s = 0;
  scanf("%d", &a);
  int d[a];
  for (n = 0; n++ - a;) scanf("%d", &d[n]);
  for (n = 1; n++ - a;) {
    s = 0;
    for (i = 0; i++ - n;) s += d[i];
    if (s == 0) ++c;
    for (m = n; m++ - a;) {
      int p = m - n;
      s -= d[p];
      s += d[m];
      if (s == 0) ++c;
    }
  }
  printf("%d\n", c);
}
