#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000;
int n, a[maxn + 5];
int C[maxn + 5];
vector<int> g[maxn + 5];
int lowbit(int x) { return x & -x; }
int Sum(int x) {
  int ret = 0;
  while (x > 0) ret += C[x], x -= lowbit(x);
  return ret;
}
void updata(int x, int d) {
  while (x <= n) {
    C[x] += d;
    x += lowbit(x);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] = min(n, a[i]);
    g[min(i - 1, a[i])].push_back(i);
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    updata(a[i], 1);
    for (int j = 0; j < g[i].size(); j++) {
      ans += Sum(n) - Sum(g[i][j] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
