#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);

class SegmentTree {
  private:
    int leaf;
    int node;
    long long na;

    std::function<long long(long long, long long)> func;

  public:
    std::vector<long long> data;

    SegmentTree(int n, auto exp, long long x);
    SegmentTree(std::vector<long long> &vec, auto exp, long long x);

    void update(int i, int v);

    long long get(int a, int b, int k, int l, int r);

};

SegmentTree::SegmentTree(int n, auto exp, long long x) {
  func = [exp](auto a, auto b){ return exp(a, b); };
  na = x * LLONG_MAX / 3;

  leaf = 1;
  while (leaf < n) leaf *= 2;
  node = 2 * leaf - 1;
  data.resize(node, na);
}

SegmentTree::SegmentTree(std::vector<long long> &vec, auto exp, long long x) {
  func = [exp](auto a, auto b){ return exp(a, b); };
  na = x * LLONG_MAX / 3;

  int n = (int)vec.size();
  leaf = 1;
  while (leaf < n) leaf *= 2;
  node = 2 * leaf - 1;
  data.resize(node, na);

  for (int i = 0; i < n; ++i) update(i, vec[i]);
}

void SegmentTree::update(int i, int v) {
  i += leaf - 1;
  data[i] = v;
  while (0 < i) {
    i = (i - 1) / 2;
    data[i] = func(data[2 * i + 1], data[2 * i + 2]);
  }
}

long long SegmentTree::get(int a, int b, int k = 0, int l = 0, int r = -1) {
  if (r < 0) r = leaf;

  if (r <= a || b <= l) return na;

  if (a <= l && r <= b) return data[k];

  long long vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
  long long vr = get(a, b, 2 * k + 2, (l + r) / 2, r);

  return func(vl, vr);
}

int main(){
  int n;
  scanf("%d", &n);

  std::vector<long long> origin(n);
  REP (i, n) {
    scanf("%lld", &origin[i]);
  }

  auto exp = [](long long a, long long b){ return a + b; };
  SegmentTree s = SegmentTree(origin, exp, 0);

  LL ans = 0;
  REP (i, n) {
    FOR (j, i + 1, n) {
      if (s.get(i, j + 1) == 0) ans++;
    }
  }

  printf("%lld\n", ans);
}
