#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300010;
int n, m, x, k, a[MAXN], c[MAXN];
long long ans, b[MAXN];
void add(int x) {
  for (; x <= m; x += x & -x) c[x]++;
}
long long ask(int x) {
  long long ans = 0;
  for (; x; x -= x & -x) ans += c[x];
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &x, &k);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) {
    b[++m] = a[i];
    if (k == 0)
      b[++m] = 1LL * a[i] / x * x + 1;
    else {
      b[++m] = 1LL * a[i] / x * x - 1LL * (k - 1) * x;
      b[++m] = 1LL * a[i] / x * x - 1LL * (k - 1) * x - (x - 1);
    }
  }
  sort(b + 1, b + m + 1);
  for (int i = 1; i <= n; i++) {
    int L, R;
    if (k == 0) {
      L = lower_bound(b + 1, b + m + 1, 1LL * a[i] / x * x + 1) - b;
      R = lower_bound(b + 1, b + m + 1, a[i]) - b;
    } else {
      L = lower_bound(b + 1, b + m + 1,
                      1LL * a[i] / x * x - 1LL * (k - 1) * x - (x - 1)) -
          b;
      R = lower_bound(b + 1, b + m + 1,
                      1LL * a[i] / x * x - 1LL * (k - 1) * x) -
          b;
    }
    int pos = lower_bound(b + 1, b + m + 1, a[i]) - b;
    add(pos);
    ans += ask(R) - ask(L - 1);
  }
  memset(c, 0, sizeof(c));
  for (int i = n; i >= 1; i--) {
    int L, R;
    if (k == 0) {
      L = lower_bound(b + 1, b + m + 1, 1LL * a[i] / x * x + 1) - b;
      R = lower_bound(b + 1, b + m + 1, a[i]) - b;
    } else {
      L = lower_bound(b + 1, b + m + 1,
                      1LL * a[i] / x * x - 1LL * (k - 1) * x - (x - 1)) -
          b;
      R = lower_bound(b + 1, b + m + 1,
                      1LL * a[i] / x * x - 1LL * (k - 1) * x) -
          b;
    }
    int pos = lower_bound(b + 1, b + m + 1, a[i]) - b;
    ans += ask(R) - ask(L - 1);
    add(pos);
  }
  cout << ans;
  return 0;
}
