#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long tree[400000], arr[200100];
std::vector<long long> vec[200100];
int maxx = 300010;
void update(int x) {
  while (x <= maxx) {
    tree[x]++;
    x += (x & -x);
  }
}
long long query(int x) {
  if (x == 0) return 0;
  int ans = 0;
  while (x) {
    ans += tree[x];
    x -= (x & -x);
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= maxx; i++) tree[i] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    arr[i] = min(arr[i], (long long)n);
    vec[arr[i]].push_back(i);
  }
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < vec[i].size(); j++) {
      update(n - vec[i][j] + 1);
    }
    if (arr[i] > i) {
      ans += query(n - i) - query(n - arr[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
