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