#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const double eps = 1e-6;
int n;
long long a[maxn];
vector<int> vec[maxn];
long long tree[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", &a[i]);
    a[i] = min(a[i], (long long)n);
    vec[min((long long)i - 1, a[i])].push_back(i);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    update(a[i], 1);
    for (auto it : vec[i]) {
      ans += query(n) - query(it - 1);
    }
  }
  printf("%I64d\n", ans);
}
