#include <bits/stdc++.h>
using namespace std;
long long ep[200005];
long long tree[400010], res;
vector<long long> vt[200005];
int n;
inline long long lowbit(int x) { return x & (-x); }
long long query(int pos) {
  long long ans = 0;
  while (pos) {
    ans += tree[pos];
    pos -= lowbit(pos);
  }
  return ans;
}
void update(int pos, int val) {
  while (pos < 200005) {
    tree[pos] += val;
    pos += lowbit(pos);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ep[i];
    ep[i] = min(ep[i], (long long)n);
    vt[min((long long)i - 1, ep[i])].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    update(ep[i], 1);
    for (auto it : vt[i]) res += query(n) - query(it - 1);
  }
  cout << res << endl;
  return 0;
}
