#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
const int inf = 0x3f3f3f3f;
int n;
long long arr[maxn], tree[maxn];
vector<int> vec[maxn];
long long lowbit(long long x) { return x & (-x); }
long long query(int pos) {
  long long ans = 0;
  while (pos) {
    ans += tree[pos];
    pos -= lowbit(pos);
  }
  return ans;
}
void update(int pos, long long val) {
  while (pos < maxn) {
    tree[pos] += val;
    pos += lowbit(pos);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &arr[i]);
    arr[i] = min(arr[i], (long long)n);
    vec[min((long long)i - 1, arr[i])].push_back(i);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    update(arr[i], 1);
    int sz = vec[i].size();
    for (int j = 0; j < sz; j++) {
      int u = vec[i][j];
      ans += query(n) - query(u - 1);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
