#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long a = 0, b = getchar(), c = 1;
  while (!isdigit(b)) c = b == '-' ? -1 : 1, b = getchar();
  while (isdigit(b)) a = a * 10 + b - '0', b = getchar();
  return a * c;
}
const int N = 200005;
long long n, ans, a[N], b[N << 1];
vector<int> g[N];
void add(int x, int y) {
  while (x <= n) b[x] += y, x += x & -x;
}
int sum(int x) {
  int res = 0;
  while (x) res += b[x], x -= x & -x;
  return res;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] > n) a[i] = n;
    ans += sum(a[i]);
    if (a[i] > i) add(i, 1), g[a[i]].push_back(i);
    for (int j = 0; j < g[i].size(); j++) add(g[i][j], -1);
  }
  printf("%lld", ans);
  return 0;
}
