#include <bits/stdc++.h>
using namespace std;
using std::cin;
using std::cout;
long long MOD = 998244353;
int main() {
  long long n, a;
  long long sum = 0;
  cin >> n;
  vector<long long> vec(n + 5), d[200010];
  for (int i = 1; i <= n; i++) {
    cin >> a;
    a = min(a, n);
    for (int c = a; c > 0; c -= c & -c) sum += vec[c];
    if (a > i) {
      for (int j = i; j <= n; j += j & -j) vec[j]++;
      d[a].push_back(i);
    }
    for (int c = 0; c < d[i].size(); c++) {
      int k = d[i][c];
      for (int c = k; c <= n; c += c & -c) vec[c]--;
    }
  }
  cout << sum;
}
