#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int MAXN = 2e5 + 10;
long long a[MAXN], ans = 0, pre[MAXN];
long long n;
int lowbit(long long x) { return x & (-x); }
void add(long long i, long long x) {
  while (i <= n) {
    pre[i] += x;
    i += lowbit(i);
  }
}
long long sum(long long x) {
  long long sum = 0;
  while (x > 0) {
    sum += pre[x];
    x -= lowbit(x);
  }
  return sum;
}
int main() {
  cin >> n;
  memset(pre, 0, sizeof(pre));
  memset(a, 0, sizeof(a));
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    add(i, a[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j <= n; j++)
      if (sum(j) - sum(i) == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
