#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
vector<int> v[maxn];
int a[maxn], n, c[maxn];
long long num;
int lowbit(int x) { return x & (-x); }
void update(int x) {
  for (int i = x; i <= n; i += lowbit(i)) c[i]++;
}
long long getsum(int x) {
  long long sum = 0;
  for (int i = x; i; i -= lowbit(i)) sum += c[i];
  return sum;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > n) a[i] = n;
    int w = min(a[i], i - 1);
    v[w].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    update(a[i]);
    for (int j = 0; j < v[i].size(); j++) {
      int w = v[i][j];
      num += getsum(n) - getsum(w - 1);
    }
  }
  printf("%lld\n", num);
  return 0;
}
