#include <bits/stdc++.h>
using namespace std;
int n;
long long int a[200000];
long long int sum[200001] = {};
int answer;
int main() {
  cin >> n;
  answer = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int l = 1; l <= n; l++) {
    for (int i = 0; i <= n - l; i++) {
      if (i == 0) {
        sum[l] = 0;
        sum[l] = sum[l - 1] + a[l - 1];
      } else {
        sum[l] += a[i + l - 1] - a[i - 1];
      }
      if (sum[l] == 0) ++answer;
    }
  }
  cout << answer << endl;
}
