#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int c[maxn];
int a[maxn];
vector<int> v[maxn];
int n;
int lowbit(int i) { return i & (-i); }
void add(int x, int y) {
  for (int i = x; i <= n; i += lowbit(i)) c[i] += y;
}
long long getsum(int x) {
  long long ans = 0;
  for (int i = x; i > 0; i -= lowbit(i)) {
    ans += c[i];
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] = min(a[i], n);
    v[min(i - 1, a[i])].push_back(i);
  }
  long long ant = 0;
  for (int i = 1; i <= n; i++) {
    add(a[i], 1);
    for (vector<int>::iterator it = v[i].begin(); it != v[i].end(); it++) {
      ant += getsum(n) - getsum(*it - 1);
    }
  }
  cout << ant << endl;
}
