#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll bs(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]>=k)&&(m==0||(A[m-1])<k))
        return m;
        else if(A[m]>=k)
        r=m-1;
        else
        l=m+1;
    }
    return -1;
}
ll bs1(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]<=k)&&((m==A.size()-1)||(A[m+1])>k))
        return m;
        else if(A[m]<=k)
        l=m+1;
        else
        r=m-1;
    }
    return -1;
}

int main()
{
    ll n,x,k;
	cin>>n>>x>>k;
vector<ll> A(n);
	for(ll i=0;i<n;i++)
	{
	cin>>A[i];
	}
	sort(A.begin(),A.end());
	ll count=0;

for(ll i=0;i<n;i++)
{ll k1=A[i]/x;
ll maxi,mini;
    if(A[i]%x==0)
    {
     mini=((k1+k-1)*x);
     if(k==0)
     continue;
    }
    else
     mini=((k1+k)*x);

mini=max(A[i],mini);
   maxi =mini+x-1;
  // cout<<mini<<" "<<maxi;
    mini=bs(A,mini);

  if(mini!=-1)
  {
    maxi=bs1(A,maxi);
    //cout<<mini<<" "<<maxi<<endl;
   count+=(maxi-mini+1);
  }

    }
    cout<<count<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll bs(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]>=k)&&(m==0||(A[m-1])<k))
        return m;
        else if(A[m]>=k)
        r=m-1;
        else
        l=m+1;
    }
    return -1;
}
ll bs1(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]<=k)&&((m==A.size()-1)||(A[m+1])>k))
        return m;
        else if(A[m]<=k)
        l=m+1;
        else
        r=m-1;
    }
    return -1;
}

int main()
{
    ll n,x,k;
	cin>>n>>x>>k;
vector<ll> A(n);
	for(ll i=0;i<n;i++)
	{
	cin>>A[i];
	}
	sort(A.begin(),A.end());
	ll count=0;

for(ll i=0;i<n;i++)
{ll k1=A[i]/x;
ll maxi,mini;
    if(A[i]%x==0)
    {
     mini=((k1+k-1)*x);
     if(k==0)
     continue;
    }
    else
     mini=((k1+k)*x);
     maxi =mini+x-1;
mini=max(A[i],mini);

  // cout<<mini<<" "<<maxi;
    mini=bs(A,mini);

  if(mini!=-1)
  {
    maxi=bs1(A,maxi);
//cout<<mini<<" "<<maxi<<endl;
   count+=(maxi-mini+1);
  }

    }
    cout<<count<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll bs(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]>=k)&&(m==0||(A[m-1])<k))
        return m;
        else if(A[m]>=k)
        r=m-1;
        else
        l=m+1;
    }
    return -1;
}
ll bs1(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]<=k)&&((m==A.size()-1)||(A[m+1])>k))
        return m;
        else if(A[m]<=k)
        l=m+1;
        else
        r=m-1;
    }
    return -1;
}

int main()
{
    ll n,x,k;
	cin>>n>>x>>k;
vector<ll> A(n);
	for(ll i=0;i<n;i++)
	{
	cin>>A[i];
	}
	sort(A.begin(),A.end());
	ll count=0;
for(ll i=0;i<n;i++)
{ll k1=A[i]/x;
ll maxi,mini;
    if(A[i]%x==0)
    {
     mini=((k1+k-1)*x);
    }
    else
     mini=((k1+k)*x);

   maxi =mini+x-1;
   //cout<<mini<<" "<<maxi;
    mini=bs(A,mini);

    if(mini!=-1)
    {
    maxi=bs1(A,maxi);
   count+=(maxi-mini+1);
    }

    }
    cout<<count<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll bs(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]>=k)&&(m==0||(A[m-1])<k))
        return m;
        else if(A[m]>=k)
        r=m-1;
        else
        l=m+1;
    }
    return -1;
}
ll bs1(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]<=k)&&((m==A.size()-1)||(A[m+1])>k))
        return m;
        else if(A[m]<=k)
        l=m+1;
        else
        r=m-1;
    }
    return -1;
}

int main()
{
    ll n,x,k;
	cin>>n>>x>>k;
vector<ll> A(n);
	for(ll i=0;i<n;i++)
	{
	cin>>A[i];
	}
	sort(A.begin(),A.end());
	ll count=0;

for(ll i=0;i<n;i++)
{ll k1=A[i]/x;
ll maxi,mini;
    if(A[i]%x==0)
    {
     mini=((k1+k-1)*x);
    }
    else
     mini=((k1+k)*x);

     if(k==0)
     {
         if(A[i]%x==0)
         continue;
     }
mini=max(A[i],mini);
   maxi =mini+x-1;
  // cout<<mini<<" "<<maxi;
    mini=bs(A,mini);

  if(mini!=-1)
  {
    maxi=bs1(A,maxi);
    //cout<<mini<<" "<<maxi<<endl;
   count+=(maxi-mini+1);
  }

    }
    cout<<count<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll bs(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]>=k)&&(m==0||(A[m-1])<k))
        return m;
        else if(A[m]>=k)
        r=m-1;
        else
        l=m+1;
    }
    return -1;
}
ll bs1(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]<=k)&&((m==A.size()-1)||(A[m+1])>k))
        return m;
        else if(A[m]<=k)
        l=m+1;
        else
        r=m-1;
    }
    return -1;
}

int main()
{
    ll n,x,k;
	cin>>n>>x>>k;
vector<ll> A(n);
	for(ll i=0;i<n;i++)
	{
	cin>>A[i];
	}
	sort(A.begin(),A.end());
	ll count=0;

for(ll i=0;i<n;i++)
{ll k1=A[i]/x;
ll maxi,mini;
    if(A[i]%x==0)
    {
     mini=((k1+k-1)*x);
    }
    else
     mini=((k1+k)*x);

     if(k==0)
     {
         if(A[i]%x==0)
         continue;
     }
mini=max(A[i],mini);
   maxi =mini+x-1;
  // cout<<mini<<" "<<maxi;
    mini=bs(A,mini);

  if(mini!=-1)
  {
    maxi=bs1(A,maxi);
    cout<<mini<<" "<<maxi<<endl;
   count+=(maxi-mini+1);
  }

    }
    cout<<count<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll bs(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]>=k)&&(m==0||(A[m-1])<k))
        return m;
        else if(A[m]>=k)
        r=m-1;
        else
        l=m+1;
    }
    return -1;
}
ll bs1(vector<ll> &A,ll k)
{
    ll l=0;
    ll r=A.size()-1;
    while(l<=r)
    {
        ll m=(l+r)/2;
        if((A[m]<=k)&&((m==A.size()-1)||(A[m+1])>k))
        return m;
        else if(A[m]<=k)
        l=m+1;
        else
        r=m-1;
    }
    return -1;
}

int main()
{
    ll n,x,k;
	cin>>n>>x>>k;
vector<ll> A(n);
	for(ll i=0;i<n;i++)
	{
	cin>>A[i];
	}
	sort(A.begin(),A.end());
	ll count=0;
for(ll i=0;i<n;i++)
{ll k1=A[i]/x;
ll maxi,mini;
    if(A[i]%x==0)
    {
     mini=((k1+k-1)*x);
    }
    else
     mini=((k1+k)*x);
mini=max(A[i],mini);
   maxi =mini+x-1;
  // cout<<mini<<" "<<maxi;
    mini=bs(A,mini);

  if(mini!=-1)
  {
    maxi=bs1(A,maxi);
    // cout<<mini<<" "<<maxi<<endl;
   count+=(maxi-mini+1);
  }

    }
    cout<<count<<endl;

}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        int l = i  , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        ans += r - l + 1 ;
        if(r - l + 1 == 0 || a[r] != a[i]) continue ;
        start = l , end = r ;
        int start1 = l , end1 = r ;
        l = r , r = -1 ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                l = mid ;
                end = mid - 1 ;
            }
            else if(a[mid] < a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        start = start1 , end = end1 ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if(a[mid] > a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        if(r == 0 || l < 0) continue;
//        cout << l << ' ' << r << '\n';
        ans += r - l ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        int l = i + 1 , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        ans += r - l + 1 ;
        if(r - l + 1 == 0 || a[r] != a[i]) continue ;
        start = l , end = r ;
        int start1 = l , end1 = r ;
        l = r + 1, r = -1 ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                l = mid ;
                end = mid - 1 ;
            }
            else if(a[mid] < a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        start = start1 , end = end1 ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if(a[mid] > a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        if(r == 0 || l < 0) continue;
//        cout << l << ' ' << r << '\n';
        ans += r - l ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        int l = i  , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }

        ans += r - l + 1 ;
        if(r - l + 1 == 0 || a[r] != a[i]) continue ;
        int sz = upper_bound(a + l, a + r , a[i])  - lower_bound(a + l, a + r , a[i]);
        ans += sz ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        if(target < 0) continue ;
        int l = i  , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        ans += r - l + 1 ;
        if(r - l + 1 == 0 || a[r] != a[i]) continue ;
        start = l , end = r ;
        int start1 = l , end1 = r ;
        l = r , r = -1 ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                l = mid ;
                end = mid - 1 ;
            }
            else if(a[mid] < a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        start = start1 , end = end1 ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if(a[mid] > a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        if(r == 0 || l < 0) continue;
//        cout << l << ' ' << r << '\n';
        ans += r - l ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        if(target <= 0) continue;
        int l = i  , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end){
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }

        ans += r - l + 1 ;
        if(r == -1 || (r != -1 && a[r] < a[i])) continue ;
        int sz = upper_bound(a + l, a + r , a[i])  - lower_bound(a + l, a + r , a[i]);
        ans += sz ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        int l = i , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        int sz = r - l + 1;
        if(r - l + 1 > 0 && a[i] == a[l])
            ans += 2 * sz - 1;
        else
            ans += r - l + 1 ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        if(target < 0) continue;
        int l = i  , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end){
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }

        ans += r - l + 1 ;
        if(r == -1 || (r != -1 && a[r] < a[i])) continue ;
        int sz = upper_bound(a + l, a + r , a[i])  - lower_bound(a + l, a + r , a[i]);
        ans += sz ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        int l = i + 1 , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        ans += r - l + 1 ;
        if(r - l + 1 == 0) continue ;
        start = l , end = r ;
        int start1 = l , end1 = r ;
        l = r + 1, r = -1 ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                l = mid ;
                end = mid - 1 ;
            }
            else if(a[mid] < a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        start = start1 , end = end1 ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if(a[mid] > a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        if(r == 0 || l < 0) continue;
//        cout << l << ' ' << r << '\n';
        ans += r - l ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        if(target < 0) continue;
        int l = i  , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end){
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;

        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        if(a[i] / x - (a[l] - 1) / x != k) continue ;
        ans += r - l + 1 ;
        if(r == -1 || (r != -1 && a[r] < a[i])) continue ;
        int sz = upper_bound(a + l, a + r , a[i])  - lower_bound(a + l, a + r , a[i]);
        ans += sz ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        int l = i , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        ans += r - l + 1 ;
        start = l , end = r ;
        int start1 = l , end1 = r ;
        l = r , r = start ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                l = mid ;
                end = mid - 1 ;
            }
            else if(a[mid] < a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        start = start1 , end = end1 ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(a[mid] == a[i])
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if(a[mid] > a[i])
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }
        if(r == 0 || l < 0) continue;
//        cout << l << ' ' << r << '\n';
        ans += r - l ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <bits/stdc++.h>

using namespace std  ;

int main()
{
    ios_base :: sync_with_stdio(false) ;
    cin.tie(nullptr) ;
    int n ;
    cin >> n ;
    int x , k  ;
    cin >> x >> k ;
    int a[n] ;
    for(int &x : a)cin >> x ;
    sort(a , a + n) ;
    long long ans = 0 ;
    for(int i = 0; i < n ; i++)
    {
        // r / x - (l - 1) / x = k
        int target = a[i] / x - k ;
        int l = i  , r = -1 ;
        int start = 0 , end = i ;
        while(start <= end){
            int mid = start + end >> 1 ;
            if((a[mid] - 1) / x == target)
            {
                l = mid ;
                end = mid - 1 ;
            }
            else  if((a[mid] - 1) / x > target)
                end = mid - 1 ;
            else
                start = mid + 1 ;
        }
        start = 0 , end = i ;
        while(start <= end)
        {
            int mid = start + end >> 1 ;
            if(((a[mid] - 1) / x) == target)
            {
                r = mid ;
                start = mid + 1 ;
            }
            else if((a[mid] - 1) / x < target)
                start = mid + 1 ;
            else
                end = mid - 1 ;
        }

        ans += r - l + 1 ;
        if(r == -1 || (r != -1 && a[r] < a[i])) continue ;
        int sz = upper_bound(a + l, a + r , a[i])  - lower_bound(a + l, a + r , a[i]);
        ans += sz ;

    }
    cout << ans << '\n' ;
    return 0 ;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef unsigned int uint;
#define MAX 100005
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    assert(y>=0);
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}
ll fastPow(ll x, ll y, int mod=MOD) {
    ll ans = 1;
    while(y>0) {
        if(y&1) ans = (x * ans)%mod;
        x = x*x%mod;
        y>>=1;
    }
    return ans;
}
ll gcd1(ll x, ll y) {
    ll z = y;
    while(x%y!=0) {
        z = x%y; x = y; y = z;
    }
    return z;
}

ll x,a[MAX],ans;
void fmain(int ID) {
    scanf("%d%lld%d", &n,&x,&k);
    REQ(i,n) {
        scanf("%lld", a+i);
    }
    sort(a+1,a+1+n);
    REQ(i,n) {
        ll tar = a[i]+x-a[i]%x +x*k-1;
        ll L=tar+1-x;
        L=max(L,a[i]);
        if (tar<L) continue;;
        int j=upper_bound(a+1, a+n+1, tar)-a;
        int jj=lower_bound(a+1, a+n+1, L)-a;
        ans += j-jj;
    }
    printf("%lld\n", ans);
}
int main() {
    int t=1;
//    scanf("%d", &t);
    REQ(i,t) {
        fmain(i);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef unsigned int uint;
#define MAX 100005
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    assert(y>=0);
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}
ll fastPow(ll x, ll y, int mod=MOD) {
    ll ans = 1;
    while(y>0) {
        if(y&1) ans = (x * ans)%mod;
        x = x*x%mod;
        y>>=1;
    }
    return ans;
}
ll gcd1(ll x, ll y) {
    ll z = y;
    while(x%y!=0) {
        z = x%y; x = y; y = z;
    }
    return z;
}

ll x,a[MAX],ans;
void fmain(int ID) {
    scanf("%d%lld%d", &n,&x,&k);
    REQ(i,n) {
        scanf("%lld", a+i);
    }
    sort(a+1,a+1+n);
    REQ(i,n) {
        ll tar = a[i]+ (x-a[i]%x)%x +x*k-1;
        ll L=tar+1-x;
        L=max(L,a[i]);
        if (tar<L) continue;;
        int j=upper_bound(a+1, a+n+1, tar)-a;
        int jj=lower_bound(a+1, a+n+1, L)-a;
        ans += j-jj;
    }
    printf("%lld\n", ans);
}
int main() {
    int t=1;
//    scanf("%d", &t);
    REQ(i,t) {
        fmain(i);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef unsigned int uint;
#define MAX 100005
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    assert(y>=0);
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}
ll fastPow(ll x, ll y, int mod=MOD) {
    ll ans = 1;
    while(y>0) {
        if(y&1) ans = (x * ans)%mod;
        x = x*x%mod;
        y>>=1;
    }
    return ans;
}
ll gcd1(ll x, ll y) {
    ll z = y;
    while(x%y!=0) {
        z = x%y; x = y; y = z;
    }
    return z;
}

ll x,a[MAX],ans;
void fmain(int ID) {
    scanf("%d%lld%d", &n,&x,&k);
    REQ(i,n) {
        scanf("%lld", a+i);
    }
    sort(a+1,a+1+n);
    REQ(i,n) {
        ll tar = a[i]+a[i]%x +x*k-1;
        ll L=tar+1-x;
        L=max(L,a[i]);
        if (tar<L) continue;;
        int j=upper_bound(a+1, a+n+1, tar)-a;
        int jj=lower_bound(a+1, a+n+1, L)-a;
        ans += j-jj;
    }
    printf("%lld\n", ans);
}
int main() {
    int t=1;
//    scanf("%d", &t);
    REQ(i,t) {
        fmain(i);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef unsigned int uint;
#define MAX 100005
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    assert(y>=0);
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}
ll fastPow(ll x, ll y, int mod=MOD) {
    ll ans = 1;
    while(y>0) {
        if(y&1) ans = (x * ans)%mod;
        x = x*x%mod;
        y>>=1;
    }
    return ans;
}
ll gcd1(ll x, ll y) {
    ll z = y;
    while(x%y!=0) {
        z = x%y; x = y; y = z;
    }
    return z;
}

ll x,a[MAX],ans;
void fmain(int ID) {
    scanf("%d%lld%d", &n,&x,&k);
    REQ(i,n) {
        scanf("%lld", a+i);
    }
    sort(a+1,a+1+n);
    REQ(i,n) {
        ll tar = a[i]+a[i]%x +x*k-1;
        ll L=tar+1-x;
//        L=max(L,a[i]);
        if (tar<L) continue;;
        int j=upper_bound(a+1, a+n+1, tar)-a;
        int jj=lower_bound(a+1, a+n+1, L)-a;
        ans += j-jj;
    }
    printf("%lld\n", ans);
}
int main() {
    int t=1;
//    scanf("%d", &t);
    REQ(i,t) {
        fmain(i);
    }
    return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, k, left, right;
	lli ans = 0;
	cin >> n >> x >> k;
	vi arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	for (auto it = arr.begin(); it != arr.end(); it++)
	{
		left = (*it - 1) / x;
		left = (left + k) * x;
		right = left + x - 1;
		auto i1 = lower_bound(all(arr), left);
		auto i2 = upper_bound(all(arr), left);
		auto i3 = upper_bound(all(arr), right);
		ans += i3 - i1;
		// cout << *it << " " << i3 - i1 << endl;
		if (*i2 == *i1)
		{
			ans += max(0, i2 - i1 - 1);
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, k, left, right;
	lli ans = 0;
	cin >> n >> x >> k;
	vi arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	for (auto it = arr.begin(); it != arr.end(); it++)
	{
		left = (*it - 1) / x;
		left = (left + k) * x;
		right = left + x - 1;
		auto i1 = lower_bound(it, arr.end(), left), i2 = upper_bound(it, arr.end(), right);
		ans += i2 - i1;
		ans += max(0, upper_bound(it, arr.end(), left) - i1 - 1);
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, k, left, right;
	lli ans = 0;
	cin >> n >> x >> k;
	vi arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	for (int i = 0; i < n; i++)
	{
		left = (arr[i] - 1) / x;
		left = (left + k) * x;
		right = left + x - 1;
		ans += upper_bound(all(arr), right) - lower_bound(all(arr), left);
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, k, left, right;
	lli ans = 0;
	cin >> n >> x >> k;
	vi arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	for (auto it = arr.begin(); it != arr.end(); it++)
	{
		left = (*it - 1) / x;
		left = (left + k) * x;
		right = left + x - 1;
		auto i1 = lower_bound(lower_bound(all(arr), *it), arr.end(), left);
		auto i2 = upper_bound(lower_bound(all(arr), *it), arr.end(), left);
		auto i3 = upper_bound(lower_bound(all(arr), *it), arr.end(), right);
		ans += i3 - i1;
		// cout << *it << " " << i3 - i1 << endl;
		if (*i2 == *i1)
		{
			ans += max(0, i2 - i1);
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, k, minInd, maxInd, curr, ans = 0;
	cin >> n >> x >> k;
	vi arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	for (int i = 0; i < n; i++)
	{
		minInd = -1;
		maxInd = -1;
		for (int j = i; j < n; j++)
		{
			curr = arr[j] / x - (arr[i] - 1) / x;
			if (curr == k)
			{
				minInd = (minInd == -1 ? j : minInd);
				maxInd = j;
			}
			else if (curr > k)
			{
				break;
			}
		}
		// cout << arr[i] << " " << minInd << " " << maxInd << endl;
		ans += maxInd - minInd + (minInd != -1);
		if (minInd != -1 && arr[i] == arr[maxInd] && i != maxInd)
		{
			ans += maxInd - minInd;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, k, minInd, maxInd, curr, l, r, mid;
	lli ans = 0;
	cin >> n >> x >> k;
	vi arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	for (int i = 0; i < n; i++)
	{
		minInd = -1;
		maxInd = -1;
		l = i;
		r = n - 1;
		// for maxInd
		while (l <= r)
		{
			mid = l + (r - l) / 2;
			curr = arr[mid] / x - (arr[i] - 1) / x;
			if (curr == k)
			{
				maxInd = mid;
				l = mid + 1;
			}
			else if (curr > k)
			{
				r = mid - 1;
			}
			else
			{
				l = mid + 1;
			}
		}

		l = i;
		r = n - 1;
		// for minInd
		while (l <= r)
		{
			mid = l + (r - l) / 2;
			curr = arr[mid] / x - (arr[i] - 1) / x;
			if (curr == k)
			{
				minInd = mid;
				r = mid - 1;
			}
			else if (curr > k)
			{
				r = mid - 1;
			}
			else
			{
				l = mid + 1;
			}
		}
		ans += maxInd - minInd + (minInd != -1);
		if (minInd != -1 && arr[i] == arr[maxInd] && i != maxInd)
		{
			ans += maxInd - minInd;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n, x, k, left, right, ans = 0;
	cin >> n >> x >> k;
	vi arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	for (auto it = arr.begin(); it != arr.end(); it++)
	{
		left = (*it - 1) / x;
		left = (left + k) * x;
		right = left + x - 1;
		auto i1 = lower_bound(lower_bound(all(arr), *it), arr.end(), left);
		auto i2 = upper_bound(lower_bound(all(arr), *it), arr.end(), left);
		auto i3 = upper_bound(lower_bound(all(arr), *it), arr.end(), right);
		ans += i3 - i1;
		if (*i2 == *i1)
		{
			ans += max(0, i2 - i1);
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, k, minInd, maxInd, curr, ans = 0;
	cin >> n >> x >> k;
	vi arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	for (int i = 0; i < n; i++)
	{
		minInd = -1;
		maxInd = -1;
		for (int j = i; j < n; j++)
		{
			curr = arr[j] / x - (arr[i] - 1) / x;
			if (curr == k)
			{
				minInd = (minInd == -1 ? j : minInd);
				maxInd = j;
			}
		}
		// cout << arr[i] << " " << minInd << " " << maxInd << endl;
		ans += maxInd - minInd + (minInd != -1);
		if (minInd != -1 && arr[minInd] == arr[maxInd] && minInd != maxInd)
		{
			ans += maxInd - minInd;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, k, minInd, maxInd, curr, ans = 0, l, r, mid;
	cin >> n >> x >> k;
	vi arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	for (int i = 0; i < n; i++)
	{
		minInd = -1;
		maxInd = -1;
		l = i;
		r = n - 1;
		// for maxInd
		while (l <= r)
		{
			mid = l + (r - l) / 2;
			curr = arr[mid] / x - (arr[i] - 1) / x;
			if (curr == k)
			{
				maxInd = mid;
				l = mid + 1;
			}
			else if (curr > k)
			{
				r = mid - 1;
			}
			else
			{
				l = mid + 1;
			}
		}

		l = i;
		r = n - 1;
		// for minInd
		while (l <= r)
		{
			mid = l + (r - l) / 2;
			curr = arr[mid] / x - (arr[i] - 1) / x;
			if (curr == k)
			{
				minInd = mid;
				r = mid - 1;
			}
			else if (curr > k)
			{
				r = mid - 1;
			}
			else
			{
				l = mid + 1;
			}
		}
		ans += maxInd - minInd + (minInd != -1);
		if (minInd != -1 && arr[i] == arr[maxInd] && i != maxInd)
		{
			ans += maxInd - minInd;
		}
	}
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std ;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int>
long long MOD  = 1e9+7;

signed main(){
    fast;
    int n,x,k;
    cin >> n >> x >> k;
    vector <int> a(n);
    for(int i=0 ; i<n ; i++){
        cin >> a[i];
    }
    sort(all(a));
    int ans = 0;
    if(k==0){
        cout << n << endl;
        return 0;
    }
    for(int i=0 ; i<n ; i++){
        int xx = a[i];
        int val,val2;
        if(xx<x){
            val = x;
        }
        else{
            if(xx%x==0){
                int div = xx/x;
                val = div*x;
            }
            else{
                int div = xx/x;
                val = (div+1)*(x);
            }

        }
        int fact = (val)/x;
        int s1 = x*(fact+k-1);
        int s2 = x*(fact+k);
        //cout << s1 << " " << s2 << endl;
        auto it1 = lb(all(a),s1);
        auto it2 = lb(all(a),s2);
        int o = ans;
        if(it1!=a.end()){
            if(it2!=a.end()){
                it2--;
                ans = ans + (it2-it1+1);
            }
            else{
                ans = ans + (n-(it1-  a.begin()));
            }
        }
        //cout << ans - o << endl;
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std ;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int>
long long MOD  = 1e9+7;

signed main(){
    fast;
    int n,x,k;
    cin >> n >> x >> k;
    vector <int> a(n);
    for(int i=0 ; i<n ; i++){
        cin >> a[i];
    }
    sort(all(a));
    if(k==0)
    {
        int ans = 0;
        for(int i=0 ; i<n; i++){
            if(a[i]%x==0)
                continue;
            int lpwer =a[i]/x+1;
            auto it=lower_bound(all(a),x*l);
            auto it2=lower_bound(all(a),a[i]);
            ans+=(it-it2);
        }
        cout << ans << endl;
        return 0;
    }

    int ans = 0;
    for(int i=0 ; i<n ; i++){
        int xx = a[i];
        int val,val2;
        if(xx<x){
            val = x;
        }
        else{
            if(xx%x==0){
                int div = xx/x;
                val = div*x;
            }
            else{
                int div = xx/x;
                val = (div+1)*(x);
            }

        }
        int fact = (val)/x;
        int s1 = x*(fact+k-1);
        int s2 = x*(fact+k);
        //cout << s1 << " " << s2 << endl;
        auto it1 = lb(all(a),s1);
        auto it2 = lb(all(a),s2);
        int o = ans;
        if(it1!=a.end()){
            if(it2!=a.end()){
                it2--;
                ans = ans + (it2-it1+1);
            }
            else{
                ans = ans + (n-(it1-  a.begin()));
            }
        }
        //cout << ans - o << endl;
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std ;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int>
long long MOD  = 1e9+7;

signed main(){
    fast;
    int n,x,k;
    cin >> n >> x >> k;
    vector <int> a(n);
    for(int i=0 ; i<n ; i++){
        cin >> a[i];
    }
    sort(all(a));
    if(k==0)
    {
        int ans = 0;
        for(int i=0 ; i<n; i++){
            if(a[i]%x==0)
                continue;
            int lower =a[i]/x+1;
            auto it=lower_bound(all(a),x*lower);
            auto it2=lower_bound(all(a),a[i]);
            ans+=(it-it2);
        }
        cout << ans << endl;
        return 0;
    }

    int ans = 0;
    for(int i=0 ; i<n ; i++){
        int xx = a[i];
        int val,val2;
        if(xx<x){
            val = x;
        }
        else{
            if(xx%x==0){
                int div = xx/x;
                val = div*x;
            }
            else{
                int div = xx/x;
                val = (div+1)*(x);
            }

        }
        int fact = (val)/x;
        int s1 = x*(fact+k-1);
        int s2 = x*(fact+k);
        //cout << s1 << " " << s2 << endl;
        auto it1 = lb(all(a),s1);
        auto it2 = lb(all(a),s2);
        int o = ans;
        if(it1!=a.end()){
            if(it2!=a.end()){
                it2--;
                ans = ans + (it2-it1+1);
            }
            else{
                ans = ans + (n-(it1-  a.begin()));
            }
        }
        //cout << ans - o << endl;
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std ;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int>
long long MOD  = 1e9+7;

signed main(){
    fast;
    int n,x,k;
    cin >> n >> x >> k;
    vector <int> a(n);
    for(int i=0 ; i<n ; i++){
        cin >> a[i];
    }
    sort(all(a));
    int ans = 0;
    for(int i=0 ; i<n ; i++){
        int xx = a[i];
        int val,val2;
        if(xx<x){
            val = x;
        }
        else{
            if(xx%x==0){
                int div = xx/x;
                val = div*x;
            }
            else{
                int div = xx/x;
                val = (div+1)*(x);
            }

        }
        int fact = (val)/x;
        int s1 = x*(fact+k-1);
        int s2 = x*(fact+k);
        //cout << s1 << " " << s2 << endl;
        auto it1 = lb(all(a),s1);
        auto it2 = lb(all(a),s2);
        int o = ans;
        if(it1!=a.end()){
            if(it2!=a.end()){
                it2--;
                ans = ans + (it2-it1+1);
            }
            else{
                ans = ans + (n-(it1-  a.begin()));
            }
        }
        //cout << ans - o << endl;
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, x, k, a[100005], ans;
map<int, int> mp;

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> x >> k;
	for(int i = 1; i <= n; i++){
	    cin >> a[i];
	    mp[a[i] / x]++;
	}
	for(int i = 1; i <= n; i++){
	    if(a[i] % x) ans += mp[(a[i] / x) + k];
	    else if(k) ans += mp[(a[i] / x) + (k - 1)];
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, x, k, a[100005], ans;
map<int, int> mp;

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> x >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	int streak = 1;
	for(int i = 1; i <= n; i++){
	    mp[(a[i] / x)]++;
	    if(a[i] == a[i + 1]){
	        streak++;
	        continue;
	    }
	    if(a[i] % x) ans += streak * mp[(a[i] / x) + k];
	    else if(k) ans += streak * mp[(a[i] / x) + (k - 1)];
	    streak = 1;
	    //cout << ans << "\n";
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, x, k, a[100005], ans;
map<int, int> mp;

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> x >> k;
	for(int i = 1; i <= n; i++){
	    cin >> a[i];
	    mp[a[i] / x]++;
	}
	for(int i = 1; i <= n; i++){
	    if(a[i] % x) ans += mp[(a[i] / x) + k];
	    else ans += mp[(a[i] / x) + (k - 1)];
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, x, k, a[100005], ans;
map<int, int> mp;

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> x >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++){
	    mp[(a[i] / x)]++;
	    if(a[i] % x) ans += mp[(a[i] / x) + k];
	    else if(k) ans += mp[(a[i] / x) + (k - 1)];
	    //cout << ans << "\n";
	}
	cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,K;
    cin >> N >> X >> K;
    vec<int> A(N);
    map<int,ll> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]/X]++;
    }
    ll ans = 0;
    sort(A.begin(),A.end());
    int c = 0;
    for(int i=0;i<N;i++){
        int a = (A[i]-1)/X;
        ans += mp[K+a];
        c++;
        if(i+1<N && A[i]!=A[i+1]){
            while(c--) mp[A[i]/X]--;
        }
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,K;
    cin >> N >> X >> K;
    vec<int> A(N);
    map<int,ll> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]/X]++;
    }
    ll ans = 0;
    sort(A.begin(),A.end());
    int c = 0;
    for(int i=0;i<N;i++){
        int a = (A[i]-1)/X;
        ans += mp[K+a];
        if(i+1<N && A[i]!=A[i+1]) while(c-- ) mp[A[i]/X]--;
        c++;
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,K;
    cin >> N >> X >> K;
    vec<int> A(N);
    map<int,ll> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]/X]++;
    }
    ll ans = 0;
    sort(A.begin(),A.end());
    for(int i=0;i<N;i++){
        int a = (A[i]-1)/X;
        ans += mp[K+a];
        if(i+1<N && A[i]!=A[i+1]) mp[A[i]/X]--;
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,K;
    cin >> N >> X >> K;
    vec<int> A(N);
    map<int,ll> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]/X]++;
    }
    ll ans = 0;
    sort(A.begin(),A.end());
    int c = 1;
    for(int i=0;i<N;i++){
        int a = (A[i]-1)/X;
        ans += mp[K+a];
        if(i+1<N && A[i]!=A[i+1]) while(c--) mp[A[i]/X]--;
        c++;
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,K;
    cin >> N >> X >> K;
    vec<int> A(N);
    map<int,ll> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]/X]++;
    }
    ll ans = 0;
    for(int i=0;i<N;i++){
        int a = (A[i]-1)/X;
        if(mp.count(K+a)) ans += mp[K+a];
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,K;
    cin >> N >> X >> K;
    vec<int> A(N);
    map<int,ll> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]/X]++;
    }
    ll ans = 0;
    sort(A.begin(),A.end());
    int c = 0;
    for(int i=0;i<N;i++){
        int a = (A[i]-1)/X;
        ans += mp[K+a];
        c++;
        if(i+1<N && A[i]!=A[i+1]){
            for(int j=0;j<c;j++) mp[A[i]/X]--;
            c = 0;
        }
    }
    cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,K;
    cin >> N >> X >> K;
    vec<int> A(N);
    map<int,ll> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]/X]++;
    }
    ll ans = 0;
    sort(A.begin(),A.end());
    int c = 0;
    for(int i=0;i<N;i++){
        int a = (A[i]-1)/X;
        ans += mp[K+a];
        c++;
        if(i+1<N && A[i]!=A[i+1]) for(int j=0;j<c;j++) mp[A[i]/X]--;
    }
    cout << ans << "\n";
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define gll greater<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
    ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool fun(string &s,string &t){
	if(s.sz!=t.sz)return s.sz<t.sz;

	return s<t;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,d,r;
	cin>>n>>m>>k;
	vll a;
	map<ll,ll> mp;
	for(i=0;i<n;i++){
		cin>>x;
		mp[x]++;
	}
	ll ans=0;
	for(auto x:mp){
		if(k==0 || x.ff%m==0)
		ans+=(x.ss*x.ss);
		a.pb(x.ff);
	}
	if(k==0){
		cout<<ans<<endl;
		return;
	}
	n=a.sz;
	sort(all(a));
	// ll ans=0;
	vll b(n+10);
	for(i=0;i<n;i++){
		b[i+1]+=b[i];
		b[i+1]+=mp[a[i]];
	}
	// for(i=0;i<n;i++){
	// 	cout<<a[i]<<" ";
	// }cout<<endl;
	// for(i=0;i<n;i++){
	// 	cout<<b[i]<<" ";
	// }cout<<endl;
	ll mid;
	for(i=0;i<n-1;i++){
		l=i,r=n-1;
		ll temp=0;
		while(l<=r){
			mid=(l+r)/2;
			ll tt=(a[mid]-a[i])/m;
			if(a[i]%m==0)tt++;

			if(tt==k){
				temp=(b[mid+1]-b[i+1])*mp[a[mid]];
				// cout<<temp<<" "<<mid<<" "<<i<< endl;
				l=mid+1;
			}else if(tt<k){
				l=mid+1;
			}else{
				r=mid-1;
			}
		}
		ans+=temp;
	}
	cout<<ans<<endl;
}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define gll greater<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
    ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool fun(string &s,string &t){
	if(s.sz!=t.sz)return s.sz<t.sz;

	return s<t;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,d,r;
	cin>>n>>m>>k;
	vll a(n);
	map<ll,ll> mp;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	sort(all(a));
	for(i=0;i<n;i++){
		ll reql=((a[i]-1)/m + k)*m;
		ll reqr=((a[i]-1)/m + k+ 1)*m;
		// cout<<mini<<" "<<maxi<<endl;
		if(k == 0)	reql = a[i];
		ll low=0,high=n-1;
		ll mid;
		ll left=-1;
		ll right=-1;
		while(low <= high) {
			mid = (low + high)/2;
			if(a[mid] >= reql) {
				left = mid;
				high = mid - 1;
			} else
				low = mid + 1;
		}
		low = 0 , high = n-1;
		while(low <= high) {
			mid = (low + high)/2;
			if(a[mid] >= reqr) {
				right = mid;
				high = mid - 1;
			} else
				low = mid + 1;
		}
		if(left == -1) continue;
		if(right == -1)   ans += n - left;
		else  ans += right - left;
	}
	cout<<ans;
}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define gll greater<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
    ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool fun(string &s,string &t){
	if(s.sz!=t.sz)return s.sz<t.sz;

	return s<t;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,d,r;
	cin>>n>>m>>k;
	vll a;
	map<ll,ll> mp;
	for(i=0;i<n;i++){
		cin>>x;
		mp[x]++;
	}
	ll ans=0;
	for(auto x:mp){
		// if(x.ff%m==0)ans+=x.ss;
		if(k==1 && x.ff%m==0){
			ans+=x.ss*(x.ss);
		}
		a.pb(x.ff);
	}
	if(m==1 && k==0){
		cout<<0<<endl;
		return;
	}
	if(k==0){
		cout<<n<<endl;
		return;
	}
	n=a.sz;
	sort(all(a));
	// ll ans=0;
	// cout<<ans<<endl;
	vll b(n+10);
	for(i=0;i<n;i++){
		b[i+1]+=b[i];
		b[i+1]+=mp[a[i]];
	}
	// for(i=0;i<n;i++){
	// 	cout<<a[i]<<" ";
	// }cout<<endl;
	// for(i=0;i<n;i++){
	// 	cout<<b[i]<<" ";
	// }cout<<endl;
	ll mid;
	for(i=0;i<n-1;i++){
		l=i,r=n-1;
		ll temp=-1,temp1=-1;
		while(l<=r){
			mid=(l+r)/2;
			ll tt=(a[mid]-a[i])/m;
			if(a[i]%m==0 || a[mid]%m==0)tt++;

			if(tt==k){
				temp=mid;
				// cout<<"m";
				l=mid+1;
			}else if(tt<k){
				l=mid+1;
			}else{
				r=mid-1;
			}
		}
		l=i,r=n-1;
		while(l<=r){
			mid=(l+r)/2;
			ll tt=(a[mid]-a[i])/m;
			if(a[i]%m==0 || a[mid]%m==0)tt++;

			if(tt==k){
				temp1=mid;
				// cout<<"k";
				r=mid-1;;
			}else if(tt<k){
				l=mid+1;
			}else{
				r=mid-1;
			}
		}
		// cout<<temp<<" "<<temp1<<endl;
		// cout<<(b[temp+1]-b[temp1])*mp[a[i]]<<endl;
		if(temp!=-1 && temp1!=-1)
		ans+=(b[temp+1]-b[temp1])*mp[a[i]];
	}
	cout<<ans<<endl;
}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define gll greater<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
    ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool fun(string &s,string &t){
	if(s.sz!=t.sz)return s.sz<t.sz;

	return s<t;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,d,r;
	cin>>n>>m>>k;
	vll a;
	map<ll,ll> mp;
	for(i=0;i<n;i++){
		cin>>x;
		mp[x]++;
	}
	ll ans=0;
	for(auto x:mp){
		if(x.ff%m==0)ans+=x.ss;
		if(k==1 && x.ff%m==0){
			ans+=x.ss*(x.ss-1);
		}
		a.pb(x.ff);
	}
	if(k==0){
		cout<<n<<endl;
		return;
	}
	n=a.sz;
	sort(all(a));
	// ll ans=0;
	vll b(n+10);
	for(i=0;i<n;i++){
		b[i+1]+=b[i];
		b[i+1]+=mp[a[i]];
	}
	// for(i=0;i<n;i++){
	// 	cout<<a[i]<<" ";
	// }cout<<endl;
	// for(i=0;i<n;i++){
	// 	cout<<b[i]<<" ";
	// }cout<<endl;
	ll mid;
	for(i=0;i<n-1;i++){
		l=i,r=n-1;
		ll temp=0;
		while(l<=r){
			mid=(l+r)/2;
			ll tt=(a[mid]-a[i])/m;
			if(a[i]%m==0)tt++;

			if(tt==k){
				temp=(b[mid+1]-b[i+1])*mp[a[mid]];
				// cout<<temp<<" "<<mid<<" "<<i<< endl;
				l=mid+1;
			}else if(tt<k){
				l=mid+1;
			}else{
				r=mid-1;
			}
		}
		ans+=temp;
	}
	cout<<ans<<endl;
}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define gll greater<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
    ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool fun(string &s,string &t){
	if(s.sz!=t.sz)return s.sz<t.sz;

	return s<t;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,d,r;
	cin>>n>>m>>k;
	vll a(n);
	map<ll,ll> mp;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	sort(all(a));
	for(i=0;i<n;i++){
		ll mini=a[i]+(k*m) -((a[i]%m!=0)?a[i]%m:m);
		ll maxi=a[i]+((k+1)*m) -((a[i]%m!=0)?a[i]%m:m+1);
		// cout<<mini<<" "<<maxi<<endl;
		ll temp1=lower_bound(all(a),mini)-a.begin();
		ll temp2=upper_bound(all(a),maxi)-a.begin();
		ans+=(temp2-temp1);
		// ll temp1=i,temp2=i;
		// ll mid;
		// l=0,r=n-1;
		// while(l<=r){
		// 	mid=(l+r)/2;
		// 	if(a[mid]<=mini){
		// 		r=mid-1;
		// 		temp1=mid;
		// 	}else{
		// 		l=mid+1;
		// 	}
		// }
		// l=0,r=n-1;
		// while(l<=r){
		// 	mid=(l+r)/2;
		// 	// if(a[mid]==maxi){
		// 	// 	temp2=mid;
		// 	// 	r=mid-1;
		// 	// }
		// 	if(a[mid]>=maxi){
		// 		r=mid-1;
		// 		temp2=mid;
		// 	}else{
		// 		l=mid+1;
		// 	}
		// }
		// cout<<temp2<<" "<<temp1<<endl;
		// if(a[temp2]<=maxi && a[temp1]>=mini){
		// 	ans+=(temp2-temp1);
		// }

	}
	cout<<ans;
}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define gll greater<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
    ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool fun(string &s,string &t){
	if(s.sz!=t.sz)return s.sz<t.sz;

	return s<t;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,d,r;
	cin>>n>>m>>k;
	vll a(n);
	map<ll,ll> mp;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	sort(all(a));
	for(i=0;i<n;i++){
		ll mini=a[i]+(k*m) -((a[i]%m!=0)?a[i]%m:m);
		ll maxi=a[i]+((k+1)*m) -((a[i]%m!=0)?a[i]%m:m+1);
		cout<<mini<<" "<<maxi<<endl;
		ll temp1=lower_bound(all(a),mini)-a.begin();
		ll temp2=upper_bound(all(a),maxi)-a.begin();
		ans+=(temp2-temp1);
		// ll temp1=i,temp2=i;
		// ll mid;
		// l=0,r=n-1;
		// while(l<=r){
		// 	mid=(l+r)/2;
		// 	if(a[mid]<=mini){
		// 		r=mid-1;
		// 		temp1=mid;
		// 	}else{
		// 		l=mid+1;
		// 	}
		// }
		// l=0,r=n-1;
		// while(l<=r){
		// 	mid=(l+r)/2;
		// 	// if(a[mid]==maxi){
		// 	// 	temp2=mid;
		// 	// 	r=mid-1;
		// 	// }
		// 	if(a[mid]>=maxi){
		// 		r=mid-1;
		// 		temp2=mid;
		// 	}else{
		// 		l=mid+1;
		// 	}
		// }
		// cout<<temp2<<" "<<temp1<<endl;
		// if(a[temp2]<=maxi && a[temp1]>=mini){
		// 	ans+=(temp2-temp1);
		// }

	}
	cout<<ans;
}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define gll greater<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
    ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool fun(string &s,string &t){
	if(s.sz!=t.sz)return s.sz<t.sz;

	return s<t;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,d,r;
	cin>>n>>m>>k;
	vll a(n);
	map<ll,ll> mp;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	sort(all(a));
	for(i=0;i<n;i++){
		ll mini=a[i]+(k*m) -(a[i]%m);
		ll maxi=a[i]+((k+1)*m) -(a[i]%m);
		ll temp1=lower_bound(all(a),mini)-a.begin();
		ll temp2=upper_bound(all(a),maxi)-a.begin();
		ans+=(temp2-temp1);
		// ll temp1=i,temp2=i;
		// ll mid;
		// l=0,r=n-1;
		// while(l<=r){
		// 	mid=(l+r)/2;
		// 	if(a[mid]<=mini){
		// 		r=mid-1;
		// 		temp1=mid;
		// 	}else{
		// 		l=mid+1;
		// 	}
		// }
		// l=0,r=n-1;
		// while(l<=r){
		// 	mid=(l+r)/2;
		// 	// if(a[mid]==maxi){
		// 	// 	temp2=mid;
		// 	// 	r=mid-1;
		// 	// }
		// 	if(a[mid]>=maxi){
		// 		r=mid-1;
		// 		temp2=mid;
		// 	}else{
		// 		l=mid+1;
		// 	}
		// }
		// cout<<temp2<<" "<<temp1<<endl;
		// if(a[temp2]<=maxi && a[temp1]>=mini){
		// 	ans+=(temp2-temp1);
		// }

	}
	cout<<ans;
}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define gll greater<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
    ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool fun(string &s,string &t){
	if(s.sz!=t.sz)return s.sz<t.sz;

	return s<t;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,d,r;
	cin>>n>>m>>k;
	vll a;
	map<ll,ll> mp;
	for(i=0;i<n;i++){
		cin>>x;
		mp[x]++;
	}
	ll ans=0;
	for(auto x:mp){
		if(x.ff%m==0)ans+=x.ss;
		if(k==1 && x.ff%m==0){
			ans+=x.ss*(x.ss-1);
		}
		a.pb(x.ff);
	}
	if(k==0){
		cout<<n<<endl;
		return;
	}
	n=a.sz;
	sort(all(a));
	// ll ans=0;
	vll b(n+10);
	for(i=0;i<n;i++){
		b[i+1]+=b[i];
		b[i+1]+=mp[a[i]];
	}
	// for(i=0;i<n;i++){
	// 	cout<<a[i]<<" ";
	// }cout<<endl;
	// for(i=0;i<n;i++){
	// 	cout<<b[i]<<" ";
	// }cout<<endl;
	ll mid;
	for(i=0;i<n-1;i++){
		l=i,r=n-1;
		ll temp=i,temp1=i;
		while(l<=r){
			mid=(l+r)/2;
			ll tt=(a[mid]-a[i])/m;
			if(a[i]%m==0)tt++;

			if(tt==k){
				temp=mid;
				l=mid+1;
			}else if(tt<k){
				l=mid+1;
			}else{
				r=mid-1;
			}
		}
		l=i,r=n-1;
		while(l<=r){
			mid=(l+r)/2;
			ll tt=(a[mid]-a[i])/m;
			if(a[i]%m==0)tt++;

			if(tt==k){
				temp=mid;
				r=mid-1;;
			}else if(tt<k){
				l=mid+1;
			}else{
				r=mid-1;
			}
		}

		ans+=(b[temp+1]-b[temp1+1])*mp[a[i]];
	}
	cout<<ans<<endl;
}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define gll greater<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
    ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool fun(string &s,string &t){
	if(s.sz!=t.sz)return s.sz<t.sz;

	return s<t;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,d,r;
	cin>>n>>m>>k;
	vll a;
	map<ll,ll> mp;
	for(i=0;i<n;i++){
		cin>>x;
		mp[x]++;
	}
	ll ans=0;
	for(auto x:mp){
		// if(x.ff%m==0)ans+=x.ss;
		if(k==1 && x.ff%m==0){
			ans+=x.ss*(x.ss);
		}
		a.pb(x.ff);
	}
	if(k==0){
		cout<<n<<endl;
		return;
	}
	n=a.sz;
	sort(all(a));
	// ll ans=0;
	// cout<<ans<<endl;
	vll b(n+10);
	for(i=0;i<n;i++){
		b[i+1]+=b[i];
		b[i+1]+=mp[a[i]];
	}
	// for(i=0;i<n;i++){
	// 	cout<<a[i]<<" ";
	// }cout<<endl;
	// for(i=0;i<n;i++){
	// 	cout<<b[i]<<" ";
	// }cout<<endl;
	ll mid;
	for(i=0;i<n-1;i++){
		l=i,r=n-1;
		ll temp=-1,temp1=-1;
		while(l<=r){
			mid=(l+r)/2;
			ll tt=(a[mid]-a[i])/m;
			if(a[i]%m==0 || a[mid]%m==0)tt++;

			if(tt==k){
				temp=mid;
				// cout<<"m";
				l=mid+1;
			}else if(tt<k){
				l=mid+1;
			}else{
				r=mid-1;
			}
		}
		l=i,r=n-1;
		while(l<=r){
			mid=(l+r)/2;
			ll tt=(a[mid]-a[i])/m;
			if(a[i]%m==0 || a[mid]%m==0)tt++;

			if(tt==k){
				temp1=mid;
				// cout<<"k";
				r=mid-1;;
			}else if(tt<k){
				l=mid+1;
			}else{
				r=mid-1;
			}
		}
		// cout<<temp<<" "<<temp1<<endl;
		// cout<<(b[temp+1]-b[temp1])*mp[a[i]]<<endl;
		if(temp!=-1 && temp1!=-1)
		ans+=(b[temp+1]-b[temp1])*mp[a[i]];
	}
	cout<<ans<<endl;
}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}