#include <bits/stdc++.h>
using namespace std;
namespace Flandle_Scarlet {
class BIT {
 public:
  long long tree[312345];
  long long len;
  void BuildTree(long long _len) {
    len = _len;
    memset(tree, 0, sizeof(tree));
  }
  void Add(long long pos, long long val) {
    for (long long i = pos; i <= len; i += (i & (-i))) {
      tree[i] += val;
    }
  }
  long long Query(long long pos) {
    long long ans = 0;
    for (long long i = pos; i > 0; i -= (i & (-i))) {
      ans += tree[i];
    }
    return ans;
  }
} T;
long long n, a[312345];
void R1(long long &x) {
  x = 0;
  char c = getchar();
  long long f = 1;
  while (c < '0' or c > '9') f = (c == '-') ? -1 : 1, c = getchar();
  while (c >= '0' and c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  x = (f == 1) ? x : -x;
}
void Input() {
  R1(n);
  for (long long i = 1; i <= n; ++i) R1(a[i]);
}
vector<long long> v[312345];
void Soviet() {
  T.BuildTree(n);
  for (long long i = 1; i <= n; ++i) {
    a[i] = min(a[i], n);
    v[a[i]].push_back(i);
    T.Add(i, 1);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    ans += T.Query(a[i]);
    for (auto x : v[i]) {
      T.Add(x, -1);
    }
  }
  for (long long i = 1; i <= n; ++i) {
    if (i <= a[i]) --ans;
  }
  printf("%lld\n", ans >> 1);
}
void IsMyWife() {
  if (0) {
    freopen("", "r", stdin);
    freopen("", "w", stdout);
  }
  Input();
  Soviet();
}
};  // namespace Flandle_Scarlet
int main() {
  Flandle_Scarlet::IsMyWife();
  return 0;
}
