#include <bits/stdc++.h>
using namespace std;
template <class C>
inline bool in_(const typename C::key_type& k, const C& A) {
  return A.find(k) != A.end();
}
inline bool in_(const string& s, const string& S) {
  return S.find(s) != string::npos;
}
const int maxn = 2e5 + 5;
int A[maxn], tree[2 * maxn];
void add(int i, const int value, const int n) {
  for (tree[i += n] += value; i > 1; i >>= 1)
    tree[i >> 1] = tree[i] + tree[i ^ 1];
}
int query(int i, int j, const int n) {
  int ans = 0;
  for (i += n, j += n; i < j; i >>= 1, j >>= 1) {
    if (i & 1) ans += tree[i++];
    if (j & 1) ans += tree[--j];
  }
  return ans;
}
typedef bool (*Cmp)(const int i, const int j);
bool cmp(const int i, const int j) { return A[i] > A[j]; }
int main() {
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n) {
    memset(tree, 0, sizeof(tree));
    for (int i = (1); i < (n + 1); ++i) cin >> A[i];
    priority_queue<int, vector<int>, Cmp> Q(cmp);
    long long ans = 0;
    for (int i = (1); i < (n + 1); ++i) {
      while (Q.size() && A[Q.top()] < i) {
        const int j = Q.top();
        Q.pop();
        add(j, -1, n + 1);
      }
      Q.push(i);
      const int cnt = query(0, min(A[i], n) + 1, n + 1);
      ans += cnt;
      add(i, 1, n + 1);
    }
    cout << ans << endl;
  }
  return 0;
}
