#include <bits/stdc++.h>
using namespace std;
static const int INF = 1e+9 + 7;
long long n, m;
string s, t;
int A[100000];
int main() {
  int count = 0;
  cin >> n;
  for (long long i = (0); i < (n); ++i) {
    cin >> A[i];
    if (i > 0) {
      if (A[i] + A[i - 1] == 0) {
        count++;
      }
    }
    if (i > 1) {
      if (accumulate(A, A + i + 1, 0) == 0) {
        count++;
      }
    }
  }
  for (long long i = (1); i < (n - 1); ++i) {
    for (long long j = (i + 2); j < (n); ++j) {
      if (accumulate(A + i, A + j + 1, 0) == 0) {
        count++;
      }
    }
  }
  cout << (count) << endl;
  return 0;
}
