#include <bits/stdc++.h>
using namespace std;
using INT = long long;
using pii = pair<int, int>;
vector<int> b[200100];
int a[200100];
void update(int u, int x) {
  for (; u < 200100; u += u & -u) b[u].push_back(x);
}
int calc(int u, int x, int ans = 0) {
  for (; u; u -= u & -u) {
    int id = lower_bound(b[u].begin(), b[u].end(), x) - b[u].begin();
    ans += (b[u].size() - id);
  }
  return ans;
}
int CALC(int l, int r, int x) { return calc(r, x) - calc(l - 1, x); }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(i, a[i]);
  }
  for (int i = 1; i < 200100; i++) sort(b[i].begin(), b[i].end());
  INT ans = 0;
  for (int i = 1; i < n; i++) {
    int l = i + 1, r = min(n, a[i]);
    if (r < l) continue;
    ans += CALC(l, r, i);
  }
  cout << ans << endl;
  return 0;
}
