#include <bits/stdc++.h>
int take() {
  int n;
  scanf("%d", &n);
  return n;
}
double ttake() {
  double n;
  scanf("%lf", &n);
  return n;
}
long long takes() {
  long long n;
  scanf("%lld", &n);
  return n;
}
int cas;
using namespace std;
bool approximatelyEqual(float a, float b, float epsilon) {
  return fabs(a - b) <= ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool essentiallyEqual(float a, float b, float epsilon) {
  return fabs(a - b) <= ((fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool definitelyGreaterThan(float a, float b, float epsilon) {
  return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool definitelyLessThan(float a, float b, float epsilon) {
  return (b - a) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
int bit[200005], arr[200005];
vector<int> v1[200005];
void upd(int x, int v) {
  while (x < 200005) {
    bit[x] += v;
    x += (x & -x);
  }
}
int query(int x) {
  int ans = 0;
  while (x > 0) {
    ans += bit[x];
    x -= (x & -x);
  }
  return ans;
}
int main() {
  int n = take();
  long long ans = 0;
  for (int i = 1; i <= n; i += 1) {
    arr[i] = take();
    if (arr[i] <= (200005 - 5)) v1[arr[i]].push_back(i);
    upd(i, 1);
  }
  for (int i = 1; i <= n; i += 1) {
    int d = min(n, arr[i]);
    ans += query(d);
    for (auto x : v1[i]) {
      upd(x, -1);
    }
  }
  for (int i = 1; i <= n; i += 1) {
    if (i <= arr[i]) ans--;
  }
  printf("%lld\n", ans / 2);
  { return 0; };
}
