#include <bits/stdc++.h>
using namespace std;
vector<int> vt[300000];
int n, a[300000];
int lowbit(int x) { return x & (-x); }
void add(int i, int x) {
  for (; i <= n; i += lowbit(i)) {
    vt[i].push_back(x);
  }
}
long long query(int i, int x) {
  long long s = 0;
  for (; i > 0; i -= lowbit(i)) {
    int pos = lower_bound(vt[i].begin(), vt[i].end(), x) - vt[i].begin();
    s += (vt[i].size() - pos);
  }
  return s;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    add(i, a[i]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) sort(vt[i].begin(), vt[i].end());
  for (int i = 1; i <= n; i++) {
    if (a[i] <= i) continue;
    ans += query(min(n, a[i]), i) - query(i, i);
  }
  printf("%lld\n", ans);
  return 0;
}
