#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  for (int i = 0; ((0 < int(v.size()) ? 1 : -1) < 0) ? i > int(v.size())
                                                     : i < int(v.size());
       i += (0 < int(v.size()) ? 1 : -1))
    o << setw(7) << left << v[i];
  return o << "\033[0m" << '\n' << "\033[48;5;196m\033[38;5;15m";
}
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
template <class T, class... Ts>
void debug(const T &e, const Ts &...r) {}
struct WaveletTree {
  WaveletTree *l, *r;
  int lo, hi;
  vector<int> lcount;
  WaveletTree(vector<int>::iterator from, vector<int>::iterator to, int lo,
              int hi) {
    this->lo = lo, this->hi = hi;
    if (lo == hi or from >= to) return;
    int mid = (lo + hi) >> 1;
    auto f = [mid](int x) { return x <= mid; };
    lcount.reserve(to - from + 1);
    lcount.push_back(0);
    for (auto it = from; it != to; it++)
      lcount.push_back(lcount.back() + f(*it));
    auto pivot = stable_partition(from, to, f);
    l = new WaveletTree(from, pivot, lo, mid);
    r = new WaveletTree(pivot, to, mid + 1, hi);
  }
  int lte(int a, int b, int k) {
    if (a > b or k < lo) return 0;
    if (hi <= k) return b - a + 1;
    int lc = lcount[a - 1], rc = lcount[b];
    return l->lte(lc + 1, rc, k) + r->lte(a - lc, b - rc, k);
  }
};
void _main(int tc) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; ((0 < n ? 1 : -1) < 0) ? i > n : i < n; i += (0 < n ? 1 : -1))
    cin >> a[i];
  debug(a);
  auto copy = a;
  WaveletTree wt(copy.begin(), copy.end(), *min_element(a.begin(), a.end()),
                 *max_element(a.begin(), a.end()));
  debug(a);
  auto query = [&](int l, int r, int k) {
    return (r - l + 1) - wt.lte(l, r, k - 1);
  };
  long long int cnt = 0;
  for (int i = n; ((n < 1 ? 1 : -1) < 0) ? i > 1 : i < 1;
       i += (n < 1 ? 1 : -1)) {
    debug(a[i - 1]);
    debug(i, min(i - 1, a[i - 1]), query(1, min(i - 1, a[i - 1]), i));
    cnt += query(1, min(i - 1, a[i - 1]), i);
  }
  cout << cnt << '\n';
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  for (int i = 0; ((0 < tc ? 1 : -1) < 0) ? i > tc : i < tc;
       i += (0 < tc ? 1 : -1))
    _main(i + 1);
}
