#include <bits/stdc++.h>
using namespace std;
long long n;
long long bit[200005] = {0};
long long maxPrimeFactors(long long n) {
  long long maxPrime = -1;
  while (n % 2 == 0) {
    maxPrime = 2;
    n >>= 1;
  }
  for (int i = 3; i <= sqrt(n); i += 2) {
    while (n % i == 0) {
      maxPrime = i;
      n = n / i;
    }
  }
  if (n > 2) maxPrime = n;
  return maxPrime;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long LCM, f = 0;
  if (max(a, b) % min(a, b) == 0)
    LCM = max(a, b);
  else {
    LCM = (a * b * 1LL) / gcd(a, b);
    if (LCM % a == 0 && LCM % b == 0) f = 1;
    if (!f || LCM < 0) return 0;
  }
  return LCM;
}
long long binarysearch(long long a[], long long t, long long low,
                       long long high) {
  long long mid = (low + high) / 2;
  if (t <= a[mid] && t > a[mid - 1]) {
    if (a[mid] == t)
      return mid;
    else
      return mid - 1;
  } else if (t <= a[mid - 1])
    binarysearch(a, t, low, mid - 1);
  else
    binarysearch(a, t, mid + 1, high);
}
void update(long long x, long long v) {
  for (; x <= n; x += x & -x) {
    bit[x] += v;
  }
}
long long query(long long x) {
  long long sum = 0;
  while (x > 0) {
    sum += bit[x];
    x -= x & -x;
  }
  return sum;
}
int main() {
  cin >> n;
  long long a[n + 1];
  vector<long long> list[n + 1];
  for (int i = 1; i <= n; i++) update(i, 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] > n) a[i] = n;
    list[a[i]].push_back(i);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] > i) ans += (query(a[i]) - query(i));
    for (int j = 0; j < list[i].size(); j++) {
      update(list[i][j], -1);
    }
  }
  cout << ans;
  return 0;
}
