#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <class T>
class BIT {
 public:
  BIT() {}
  BIT(int N) : N(N) { dat.assign(N, 0); }
  T sum(int i) {
    if (mp.count(i) > 0) {
      return mp[i];
    }
    int ret = 0;
    for (--i; i >= 0; i = (i & (i + 1)) - 1) ret += dat[i];
    return mp[i] = ret;
  }
  T sum(int i, int j) { return sum(j) - sum(i); }
  void add(int i, T x) {
    for (; i < N; i |= i + 1) dat[i] += x;
  }

 private:
  int N;
  vector<T> dat;
  map<int, T> mp;
};
int main() {
  int n;
  cin >> n;
  BIT<ll> bt(n);
  for (int i = 0; i < (n); ++i) {
    ll t;
    cin >> t;
    bt.add(i, t);
  }
  ll cnt = 0;
  for (int i = 0; i < (n); ++i) {
    for (int j = (i + 1); j < (n + 1); ++j) {
      if (bt.sum(j) - bt.sum(i) == 0) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
