#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T& x) {
  cin >> x;
}
void read(int& x) { scanf("%d", &x); }
void read(int64_t& x) { scanf("%lld", &x); }
void read(double& x) { scanf("%lf", &x); }
template <class T, class U, class... V>
void read(T& x, U& y, V&... z) {
  read(x);
  read(y, z...);
}
int main() {
  int n;
  read(n);
  vector<int> a(n);
  for (int i = (0); i < (n); ++i) {
    read(a[i]);
  }
  vector<int> b(n);
  partial_sum(begin(a), end(a), begin(b));
  int result = 0;
  for (int i = (0); i < (n); ++i) {
    result += count(begin(b) + i, end(b), 0);
    for (int j = (i); j < (n); ++j) {
      b[j] -= a[i];
    }
  }
  printf("%d", result);
}
