#include <bits/stdc++.h>
using namespace std;
const int MX = 2e5 + 7;
int N, A[MX], F[MX];
vector<int> sum[MX];
void add(int i, int b) {
  for (; i <= N; i += (i & -i)) F[i] += b;
}
int pre(int i) {
  int ret = 0;
  for (; i > 0; i -= (i & -i)) ret += F[i];
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    add(i, 1);
    if (A[i] <= N) sum[A[i]].push_back(i);
  }
  for (int i = 1, tmp; i <= N; i++) {
    tmp = min(N, A[i]);
    ans += pre(tmp);
    if (A[i] >= i) ans--;
    for (auto j : sum[i]) add(j, -1);
  }
  cout << ans / 2 << endl;
}
