#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)2e5 + 5;
int tree[MAXN << 2];
void build(int l, int r, int rt) {
  tree[rt] = r - l + 1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, (rt << 1));
  build(mid + 1, r, (rt << 1 | 1));
}
void update(int l, int r, int x, int rt) {
  if (l == r) {
    tree[rt] = 0;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    update(l, mid, x, (rt << 1));
  else
    update(mid + 1, r, x, (rt << 1 | 1));
  tree[rt] = tree[(rt << 1)] + tree[(rt << 1 | 1)];
}
int query(int l, int r, int x, int rt) {
  if (x == 0) return 0;
  if (r == x) return tree[rt];
  int mid = (l + r) >> 1;
  if (x <= mid)
    return query(l, mid, x, (rt << 1));
  else
    return tree[(rt << 1)] + query(mid + 1, r, x, (rt << 1 | 1));
}
int a[MAXN];
vector<int> ve[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] <= n) ve[a[i]].push_back(i);
  }
  build(1, n, 1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += query(1, n, min(i - 1, a[i]), 1);
    for (int j = 0; j < (int)ve[i].size(); j++) {
      update(1, n, ve[i][j], 1);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
