#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, l, sum = 0, flag = 0, t, a[200005], ans = 0;
struct node {
  node *left, *right;
  int count;
  node() {}
  node(int _count, node *_left, node *_right) {
    left = _left;
    right = _right;
    count = _count;
  }
  node *insert(int l, int r, int w);
};
node *root[200005];
node *null = new node(0, NULL, NULL);
node *node::insert(int l, int r, int w) {
  if (l <= w && w <= r) {
    if (l == r) return new node(this->count + 1, null, null);
    int m = (l + r) >> 1;
    return new node(this->count + 1, this->left->insert(l, m, w),
                    this->right->insert(m + 1, r, w));
  }
  return this;
}
int query(node *a, int l, int r, int k) {
  if (r < k) return 0;
  if (k <= l) return a->count;
  int m = (l + r) >> 1;
  return query(a->left, l, m, k) + query(a->right, m + 1, r, k);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  null->left = null->right = null;
  root[0] = null->insert(0, 1000000001, a[0]);
  for (i = 1; i < n; i++) {
    root[i] = root[i - 1]->insert(0, 1000000001, a[i]);
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    long long maxi = min(n - 1, a[i] - 1);
    ans += query(root[max(i, maxi)], 0, 1000000001, i + 1) -
           query(root[i], 0, 1000000001, i + 1);
  }
  cout << ans << '\n';
  return 0;
}
