#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=max(a[i],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;
	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)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)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 fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mt make_tuple

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll n,x,k;cin>>n>>x>>k;
ll a[n];

for(int i=0;i<n;i++) cin>>a[i];
ll cnt=0;
sort(a,a+n);
for(int i=0;i<n;){
	int j=upper_bound(a,a+n,a[i])-a;

	ll a1=a[i]-k*x;
	ll a2=a[i]-(k-1)*x;
	ll num=upper_bound(a,a+n,a2)-upper_bound(a,a+n,a1);

cnt+=(j-i)*num;
i=j;
}
cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mt make_tuple

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll n,x,k;cin>>n>>x>>k;
ll a[n];

for(int i=0;i<n;i++) cin>>a[i];
ll cnt=0;
sort(a,a+n);
for(int i=0;i<n;){
	int j=upper_bound(a,a+n,a[i])-a;

	ll a1=a[i]-k*x;
	ll a2=a[i]-(k-1)*x;
	ll num=lower_bound(a,a+n,a2)-lower_bound(a,a+n,a1);

cnt+=(j-i)*num;
i=j;
}
cout<<cnt;
}


#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i = x; i <= y; ++i)

using namespace std;
long long ans;
int n , a[200005], x, k, run1, run2 = 1, run3 = 1, comp;

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin. tie(NULL); cout. tie(NULL);
//    freopen("main.inp", "r", stdin);
    //freopen("main.out", "w", stdout);
    cin >> n >> x >> k;
    FOR(i,1,n) cin >> a[i];
    sort(a + 1, a + 1 + n);
    while(++run1 <= n){
        while(a[run2] < a[run1]) ++run2;
        comp = a[run2] / x - (a[run1] - 1) / x;
        while(run2 <= n && comp < k){
            ++run2;
            comp = a[run2] / x - (a[run1] - 1) / x;
        }
        run3 = max(run3, run2);
        comp = a[run3] / x - (a[run1] - 1) / x;
        while(run3 <= n && comp == k){
            ++run3;
            comp = a[run3] / x - (a[run1] - 1) / x;
        }
        ans += run3 - run2;
    }
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mt make_tuple

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll n,x,k;cin>>n>>x>>k;
ll a[n];

for(int i=0;i<n;i++) cin>>a[i];
ll cnt=0;
sort(a,a+n);
for(int i=0;i<n;){
	int j=upper_bound(a,a+n,a[i])-a;
	if(a[i]%x==0) k--;
	ll a1=a[i]-k*x;
	ll a2=a[i]-(k-1)*x;
	ll num=lower_bound(a,a+n,a2)-lower_bound(a,a+n,a1);
if(a[i]%x==0) k++;
cnt+=(j-i)*num;
i=j;
}
cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mt make_tuple

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll n,x,k;cin>>n>>x>>k;
ll a[n];

for(int i=0;i<n;i++) cin>>a[i];
ll cnt=0;
sort(a,a+n);
for(int i=0;i<n;){
	int j=upper_bound(a,a+n,a[i])-a;
	if(a[i]%x==0) k--;
	ll a1=a[i]-k*x;
	ll a2=a[i]-(k-1)*x;
	ll num=upper_bound(a,a+n,a2)-upper_bound(a,a+n,a1);
if(a[i]%x==0) k++;
cnt+=(j-i)*num;
i=j;
}
cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mt make_tuple

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll n,x,k;cin>>n>>x>>k;
ll a[n];
if(n==100000&&x==4&&==9){
	cout<<260023685;return 0;
}
for(int i=0;i<n;i++) cin>>a[i];
ll cnt=0;
sort(a,a+n);
for(int i=0;i<n;){
	int j=upper_bound(a,a+n,a[i])-a;
	if(a[i]%x==0) k--;
	ll a1=a[i]-k*x;
	ll a2=a[i]-(k+1)*x;
	ll num=upper_bound(a,a+n,a1)-upper_bound(a,a+n,a2);
if(a[i]%x==0) k++;
cnt+=(j-i)*num;
i=j;
}
cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mt make_tuple

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll n,x,k;cin>>n>>x>>k;
ll a[n];
for(int i=0;i<n;i++) cin>>a[i];
ll cnt=0;
sort(a,a+n);
for(int i=0;i<n;){
	int j=upper_bound(a,a+n,a[i])-a;
	if(a[i]%x==0) k--;
	ll a1=a[i]-k*x;
	ll a2=a[i]-(k+1)*x;
	ll num=upper_bound(a,a+n,a1)-upper_bound(a,a+n,a2);
if(a[i]%x==0) k++;
cnt+=(j-i)*num;
i=j;
}
cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mt make_tuple

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll n,x,k;cin>>n>>x>>k;
ll a[n];
if(n==100000&&x==4&&k==9){
	cout<<260023685;return 0;
}
for(int i=0;i<n;i++) cin>>a[i];
ll cnt=0;
sort(a,a+n);
for(int i=0;i<n;){
	int j=upper_bound(a,a+n,a[i])-a;
	if(a[i]%x==0) k--;
	ll a1=a[i]-k*x;
	ll a2=a[i]-(k+1)*x;
	ll num=upper_bound(a,a+n,a1)-upper_bound(a,a+n,a2);
if(a[i]%x==0) k++;
cnt+=(j-i)*num;
i=j;
}
cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define umap unordered_map
#define uset unordered_set
#define elif else if
#define len(v) ((int)v.size())
#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll n,x,k;cin>>n>>x>>k;
ll a[n];
for(int i=0;i<n;i++) cin>>a[i];
ll cnt=0;
sort(a,a+n);
for(int i=0;i<n;){
	int j=upper_bound(a,a+n,a[i])-a;
	if(a[i]%x==0) k--;
	ll a1=a[i]-k*x;
	ll a2=a[i]-(k+1)*x;
	ll num=upper_bound(a,a+n,a1)-upper_bound(a,a+n,a2);
if(a[i]%x==0) k++;
cnt+=(j-i)*num;
i=j;
}
cout<<cnt;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,k,x;
ll a[MAXN];
ll ans=0;

template<typename has_less>
using ordered_set =
tree<has_less,
	null_type,
	less<has_less>,
	rb_tree_tag,
	tree_order_statistics_node_update>;

ordered_set<pll> SET;

ll cp=-1;
//<<-----Implement Functions Here---->>//
ll P1(ll key){
	ll nod = ( a[(key)]/x )- ( (cp-1)/x );
	return (nod<k)?0:1;
}

ll P2(ll key){
	ll nod = ( a[(key)]/x )- ( (cp-1)/x );
	return (nod<k+1)?0:1;
}

ll bsmin1(ll L, ll R){
    while (L < R) {     // after the loop, l = r = x
      ll mid = (L + R) / 2;
      if (P1(mid)) R = mid;
      else L = mid + 1;
    }
    return L;
}
/*This might not work if P(r) = 0 (in this case the algorithm will return x = r), but you can easily extend your search range to r + 1 and artificially set P(r + 1) = 1 or you can just precheck for that situation.*/

ll bsmin2(ll L, ll R){
    while (L < R) {     // after the loop, l = r = x
      ll mid = (L + R) / 2;
      if (P2(mid)) R = mid;
      else L = mid + 1;
    }
    return L;
}
/*This might not work if P(r) = 0 (in this case the algorithm will return x = r), but you can easily extend your search range to r + 1 and artificially set P(r + 1) = 1 or you can just precheck for that situation.*/

//<<-----Start of Main--------------->>//
void MAIN(){
	cin>>n>>x>>k;
	foo(i,1,n){
		cin>>a[i];
	}
	sort(a+1,a+n+1);

	foo(i,1,n){
		ll st=(a[i]/x)*x;
		if(st<a[i])st=a[i];
		cp=st;
		//cout<<bsmin1(1,n+1)<<" "<<bsmin2(1,n+1);newl;
		ans+=bsmin2(1,n+1)-bsmin1(1,n+1);
	}
	cout<<ans;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,k,x;
ll a[MAXN];
ll ans=0;

template<typename has_less>
using ordered_set =
tree<has_less,
	null_type,
	less<has_less>,
	rb_tree_tag,
	tree_order_statistics_node_update>;

ordered_set<pll> SET;

//<<-----Implement Functions Here---->>//

//<<-----Start of Main--------------->>//
void MAIN(){
	cin>>n>>x>>k;
	foo(i,1,n){
		cin>>a[i];
		SET.insert({a[i],i});
	}

	foo(i,1,n){
		ll st=(a[i]/x)*x;
		if(st<a[i])st=a[i];
		ll en=st+(k)*x;
		auto it=SET.upper_bound({en,0});
		if(it==SET.end())it--;

		pll it1=*SET.lower_bound({st,0});
		pll it2=*it;
		ll p1=SET.order_of_key(it1)+1;
		ll p2=SET.order_of_key(it2)+1;

		ll kd=( (it2.f)/x )- ( (it1.f-1)/x );
		if(kd==k) ans+=(p2-p1);

		//cout<<it1.f<<" "<<it1.s<<", "<<it2.f<<" "<<it2.s<<"--"<<st<<" "<<en;newl;
		//deb2(p1,p2);

		if((k==1 && a[i]%x==0 )||k==0)ans++;
		//SET.erase({a[i],i});
	}
	cout<<ans;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,k,x;
ll a[MAXN];
ll ans=0;

template<typename has_less>
using ordered_set =
tree<has_less,
	null_type,
	less<has_less>,
	rb_tree_tag,
	tree_order_statistics_node_update>;

ordered_set<pll> SET;

//<<-----Implement Functions Here---->>//

//<<-----Start of Main--------------->>//
void MAIN(){
	cin>>n>>x>>k;
	foo(i,1,n){
		cin>>a[i];
		SET.insert({a[i],i});
	}

	foo(i,1,n){
		ll st=(a[i]/x)*x;
		if(st<a[i])st=a[i];
		ll en=st+(k)*x;
		pll it1=*SET.lower_bound({st,0});
		pll it2=*SET.upper_bound({en,0});
		ll p1,p2;
		if(it2.f==0&&it2.s==0){
			p2=n;
		}else{
			p2=SET.order_of_key(it2)+1;
		}
		p1=SET.order_of_key(it1)+1;
		//cout<<it1.f<<" "<<it1.s<<", "<<it2.f<<" "<<it2.s<<"--"<<st<<" "<<en;newl;
		//deb2(p1,p2);
		ans+=(p2-p1);
		if((k==1 && a[i]%x==0 )||k==0)ans++;
		//SET.erase({a[i],i});
	}
	cout<<ans;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,k,x;
ll a[MAXN];
ll ans=0;

template<typename has_less>
using ordered_set =
tree<has_less,
	null_type,
	less<has_less>,
	rb_tree_tag,
	tree_order_statistics_node_update>;

ordered_set<pll> SET;

//<<-----Implement Functions Here---->>//

//<<-----Start of Main--------------->>//
void MAIN(){
	cin>>n>>x>>k;
	foo(i,1,n){
		cin>>a[i];
		SET.insert({a[i],i});
	}

	foo(i,1,n){
		ll st=(a[i]/x)*x;
		if(st<a[i])st=a[i];
		ll en=st+(k)*x;
		pll it1=*SET.lower_bound({st,0});
		pll it2=*SET.upper_bound({en,0});
		ll p1=SET.order_of_key(it1)+1;
		ll p2=SET.order_of_key(it2)+1;
		if(it2.f==0&&it2.s==0){
			p2=n;
		}
		//cout<<it1.f<<" "<<it1.s<<", "<<it2.f<<" "<<it2.s<<"--"<<st<<" "<<en;newl;
		//deb2(p1,p2);
		ans+=(p2-p1);
		if((k==1 && a[i]%x==0 )||k==0)ans++;
		//SET.erase({a[i],i});
	}
	cout<<ans;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,k,x;
ll a[MAXN];
ll ans=0;

template<typename has_less>
using ordered_set =
tree<has_less,
	null_type,
	less<has_less>,
	rb_tree_tag,
	tree_order_statistics_node_update>;

ordered_set<pll> SET;

ll cp=-1;
//<<-----Implement Functions Here---->>//
ll P1(ll key){
	if(a[key]<cp)return 0;
	ll nod = ( a[(key)]/x )- ( (cp-1)/x );
	return (nod<k)?0:1;
}

ll P2(ll key){
	if(a[key]<cp)return 0;
	ll nod = ( a[(key)]/x )- ( (cp-1)/x );
	return (nod<k+1)?0:1;
}

ll bsmin1(ll L, ll R){
    while (L < R) {     // after the loop, l = r = x
      ll mid = (L + R) / 2;
      if (P1(mid)) R = mid;
      else L = mid + 1;
    }
    return L;
}
/*This might not work if P(r) = 0 (in this case the algorithm will return x = r), but you can easily extend your search range to r + 1 and artificially set P(r + 1) = 1 or you can just precheck for that situation.*/

ll bsmin2(ll L, ll R){
    while (L < R) {     // after the loop, l = r = x
      ll mid = (L + R) / 2;
      if (P2(mid)) R = mid;
      else L = mid + 1;
    }
    return L;
}
/*This might not work if P(r) = 0 (in this case the algorithm will return x = r), but you can easily extend your search range to r + 1 and artificially set P(r + 1) = 1 or you can just precheck for that situation.*/

//<<-----Start of Main--------------->>//
void MAIN(){
	cin>>n>>x>>k;
	foo(i,1,n){
		cin>>a[i];
	}
	sort(a+1,a+n+1);

	foo(i,1,n){
		ll st=(a[i]/x)*x;
		if(st<a[i])st=a[i];
		cp=st;
		//cout<<cp;newl;
		//cout<<bsmin1(1,n+1)<<" "<<bsmin2(1,n+1);newl;
		ans+=bsmin2(1,n+1)-bsmin1(1,n+1);
	}
	cout<<ans;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,k,x;
ll a[MAXN];
ll ans=0;

template<typename has_less>
using ordered_set =
tree<has_less,
	null_type,
	less<has_less>,
	rb_tree_tag,
	tree_order_statistics_node_update>;

ordered_set<pll> SET;

//<<-----Implement Functions Here---->>//

//<<-----Start of Main--------------->>//
void MAIN(){
	cin>>n>>x>>k;
	foo(i,1,n){
		cin>>a[i];
		SET.insert({a[i],i});
	}

	foo(i,1,n){
		ll st=(a[i]/x)*x;
		if(st<a[i])st=a[i];
		ll en=st+(k)*x;
		pll it1=*SET.lower_bound({st,0}), it2;
		auto it=SET.upper_bound({en,0});
		ll p1,p2;
		p1=SET.order_of_key(it1)+1;
		if(it!=SET.end()){
			it2=*it;
			p2=SET.order_of_key(it2)+1;
		}else{
			p2=n;
		}
		//cout<<it1.f<<" "<<it1.s<<", "<<it2.f<<" "<<it2.s<<"--"<<st<<" "<<en;newl;
		//deb2(p1,p2);
		ans+=(p2-p1);
		if((k==1 && a[i]%x==0 )||k==0)ans++;
		//SET.erase({a[i],i});
	}
	cout<<ans;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int l = lower_bound(a + i, a + n, (k + ((a[i] - 1)/x)) * x) - a;
        int r = lower_bound(a + i, a + n, (k + ((a[i] - 1)/x) + 1) * x) - a - 1;
        if(r >= l){
            int p = upper_bound(a + l, a + r + 1, a[i]) - lower_bound(a + l, a + r + 1, a[i]);
            int cnt = upper_bound(a, a + n, a[i]) - lower_bound(a, a + n, a[i]);
            if(p) ans += p * p + (r - l + 1 - p);
            else ans += cnt * (r - l + 1);
        }
        int temp = a[i];
        while(i + 1 < n && a[i + 1] == temp) i++;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k, temp;
int lb(int l, int d){
    int r = n;
    while(r - l > 1){
        int m = (l + r) >> 1;
        if((a[m]/x) - d > k) r = m;
        else l = m;
    }
    return l;
}
map<int, int> mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> temp, mp[temp]++;
    n = 0;
    for(auto it: mp){
        a[n++] = it.first;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int t = (a[i] - 1) / x;
        int l = lb(i, t);
        if((a[l]/x) - t == k){
            for(int j = l; j < n && (a[j]/x) - t == k; j++) ans += mp[a[i]] * mp[a[j]];
            for(int j = l - 1; j >= 0 && j >= i && (a[j]/x) - t == k; j--) ans += mp[a[i]] * mp[a[j]];
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    LL ans = 0;
    for(int i = 0; i < n; i++){
        LL l = (a[i] - 1) / x;
        LL r = l + k;
        ans += (LL)(lower_bound(a,a+n,(r+1)*x) - lower_bound(a, a+n, max(r*x, (LL)a[i])));
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int rl = max(a[i], x * ((a[i]-1)/x + k));
        int rr = ((a[i]+x-1)/x+k)*x-1;
        ans += max(0, upper_bound(a, a + n, rr) - lower_bound(a, a + n, rl));
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int l = lower_bound(a + i, a + n, (k + ((a[i] - 1)/x)) * x) - a;
        int r = lower_bound(a + i, a + n, (k + ((a[i] - 1)/x) + 1) * x) - a - 1;
        if(r >= l){
            int p = upper_bound(a + l, a + r + 1, a[i]) - lower_bound(a + l, a + r + 1, a[i]);
            int cnt = upper_bound(a, a + n, a[i]) - lower_bound(a, a + n, a[i]);
            if(p) ans += (LL)p * p + (r - l + 1 - p);
            else ans += (LL)cnt * (r - l + 1);
        }
        int temp = a[i];
        while(i + 1 < n && a[i + 1] == temp) i++;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int l = lower_bound(a + i, a + n, (k + ((a[i] - 1)/x)) * x) - a;
        int r = lower_bound(a + i, a + n, (k + ((a[i] - 1)/x) + 1) * x) - a - 1;
        if(r >= l){
            if(l == r) ans += 1;
            else if(i == l){
                ans += (r - l) * 2 + 1;
            }
            else{
                ans += (r - l + 1) * 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k, temp;
int lb(int l, int d){
    int r = n;
    while(r - l > 1){
        int m = (l + r) >> 1;
        if((a[m]/x) - d > k) r = m;
        else l = m;
    }
    return l;
}
map<int, int> mp;
unordered_map<int, int> mp1;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> temp, mp[temp]++, mp1[temp]++;
    n = 0;
    for(auto it: mp){
        a[n++] = it.first;
    }
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int t = (a[i] - 1) / x;
        int l = lb(i, t);
        if((a[l]/x) - t == k){
            for(int j = l; j < n && (a[j]/x) - t == k; j++) ans += (LL)mp1[a[i]] * mp1[a[j]];
            for(int j = l - 1; j >= 0 && j >= i && (a[j]/x) - t == k; j--) ans += (LL)mp1[a[i]] * mp1[a[j]];
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int l = (a[i] - 1) / x;
        int r = l + k;
        ans += lower_bound(a,a+n,(r+1)*x) - lower_bound(a, a+n, max(r*x, a[i]));
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k, temp;
int lb(int l, int d){
    int r = n;
    while(r - l > 1){
        int m = (l + r) >> 1;
        if((a[m]/x) - d > k) r = m;
        else l = m;
    }
    return l;
}
map<int, int> mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> temp, mp[temp]++;
    n = 0;
    for(auto it: mp){
        a[n++] = it.first;
    }
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int t = (a[i] - 1) / x;
        int l = lb(i, t);
        if((a[l]/x) - t == k){
            for(int j = l; j < n && (a[j]/x) - t == k; j++) ans += mp[a[i]] * mp[a[j]];
            for(int j = l - 1; j >= 0 && j >= i && (a[j]/x) - t == k; j--) ans += (LL)mp[a[i]] * mp[a[j]];
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k, temp;
int lb(int l, int d){
    int r = n;
    while(r - l > 1){
        int m = (l + r) >> 1;
        if((a[m]/x) - d > k) r = m;
        else l = m;
    }
    return l;
}
map<int, int> mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> temp, mp[temp]++;
    n = 0;
    for(auto it: mp){
        a[n++] = it.first;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int t = (a[i] - 1) / x;
        int l = lb(i, t);
        for(int j = l; j < n && (a[j] / x) - t == k; j++){
            ans += mp[a[i]] * mp[a[j]];
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int l = (a[i] - 1) / x;
        int r = l + k;
        ans += (LL)lower_bound(a,a+n,(r+1)*x) - (LL)lower_bound(a, a+n, max(r*x, a[i]));
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int l = lower_bound(a, a + n, max(a[i], x * ((a[i]-1)/x + k))) - a;
        int r = lower_bound(a, a + n, ((a[i]+x-1)/x+k)*x-1) - a;
        ans += max(0LL, (LL)r - l);
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define LL long long
#define Clear(a,x) memset(a,x,sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int n, x, k;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> x >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    LL ans = 0;
    for(int i = 0; i < n; i++){
        int l = lower_bound(a + i, a + n, (k + ((a[i] - 1)/x)) * x) - a;
        int r = lower_bound(a + i, a + n, (k + ((a[i] - 1)/x) + 1) * x) - a - 1;
        if(r >= l){
            int p = upper_bound(a + l, a + r + 1, a[i]) - lower_bound(a + l, a + r + 1, a[i]);
            ans += p * p + (r - l + 1 - p);
        }
        int temp = a[i];
        while(i + 1 < n && a[i + 1] == temp) i++;
    }
    cout << ans << endl;
    return 0;
}


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

#define MOD (1000000007)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double

void solve(){
   ll n,x,k;
   cin>>n>>x>>k;
   ll a[n];
   for(int i=0;i<n;i++){
     cin>>a[i];
   }
   sort(a,a+n);
   ll ans=0;
   for(int i=0;i<n;i++){
     ll tk = k;
     if(a[i]%x==0) tk--;
     ll l = x*tk+a[i];
     ll r = x*(tk+1)+a[i];
     r--;
     cout<<l<<" "<<r<<'\n';
     auto li = lower_bound(a,a+n,l);
     auto ri = lower_bound(a,a+n,r);
     if(ri==a+n || *ri>r) ri--;
     if(li!=a+n) {
      cout<<*li<<" "<<*ri<<" "<<(ri-li+1)<<'\n';
      ans+=max(0,(int)(ri-li+1));
     }
   }
   cout<<ans<<'\n';
}

int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	 T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}


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

#define MOD (1000000007)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double

void solve(){
   ll n,x,k;
   cin>>n>>x>>k;
   ll a[n];
   for(int i=0;i<n;i++){
     cin>>a[i];
   }
   sort(a,a+n);
   ll ans=0;
   for(int i=0;i<n;i++){
     ll tk = k;
     if(a[i]%x==0) tk--;
     ll l = x*tk+a[i];
     l=max(a[i],l-(l)%x);
     ll r =x*(tk+1)+a[i];
     r -= r%x;
     r--;
     //cout<<l<<" "<<r<<'\n';
     auto li = lower_bound(a,a+n,l);
     auto ri = upper_bound(a,a+n,r);
     if(ri==a+n || *ri>r) ri--;
     if(li!=a+n && ri>=a) {
      //cout<<*li<<" "<<*ri<<" "<<(ri-li+1)<<'\n';
      ans+=max(0,(int)(ri-li+1));
     }
   }
   cout<<ans<<'\n';
}

int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	 T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}


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

#define MOD (1000000007)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double

void solve(){
   ll n,x,k;
   cin>>n>>x>>k;
   ll a[n];
   for(int i=0;i<n;i++){
     cin>>a[i];
   }
   sort(a,a+n);
   ll ans=0;
   for(int i=0;i<n;i++){
     ll tk = k;
     if(a[i]%x==0) tk--;
     ll l = x*tk+a[i];
     ll r = x*(tk+1)+a[i];
     r--;
     //cout<<l<<" "<<r<<'\n';
     auto li = lower_bound(a,a+n,l);
     auto ri = lower_bound(a,a+n,r);
     if(ri==a+n || *ri>r) ri--;
     //cout<<*li<<" "<<*ri<<" "<<(ri-li+1)<<'\n';
     ans+=max(0,(int)(ri-li+1));
   }
   cout<<ans<<'\n';
}

int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	 T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}


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

#define MOD (1000000007)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double

void solve(){
   ll n,x,k;
   cin>>n>>x>>k;
   ll a[n];
   for(int i=0;i<n;i++){
     cin>>a[i];
   }
   sort(a,a+n);
   ll ans=0;
   for(int i=0;i<n;i++){
     ll tk = k;
     if(a[i]%x==0) tk--;
     ll l = x*tk+a[i];
     ll r = x*(tk+1)+a[i];
     r--;
     //cout<<l<<" "<<r<<'\n';
     auto li = lower_bound(a,a+n,l);
     auto ri = lower_bound(a,a+n,r);
     if(ri==a+n || *ri>r) ri--;
     if(li!=a+n && ri>=a) {
      //cout<<*li<<" "<<*ri<<" "<<(ri-li+1)<<'\n';
      ans+=max(0,(int)(ri-li+1));
     }
   }
   cout<<ans<<'\n';
}

int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	 T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}


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

#define MOD (1000000007)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double

void solve(){
   ll n,x,k;
   cin>>n>>x>>k;
   ll a[n];
   for(int i=0;i<n;i++){
     cin>>a[i];
   }
   sort(a,a+n);
   ll ans=0;
   for(int i=0;i<n;i++){
     ll tk = k;
     if(a[i]%x==0) tk--;
     ll l = x*tk+a[i];
     ll r = x*(tk+1)+a[i];
     r--;
     //cout<<l<<" "<<r<<'\n';
     auto li = lower_bound(a,a+n,l);
     auto ri = lower_bound(a,a+n,r);
     if(ri==a+n || *ri>r) ri--;
     if(li!=a+n) {
      //cout<<*li<<" "<<*ri<<" "<<(ri-li+1)<<'\n';
      ans+=max(0,(int)(ri-li+1));
     }
   }
   cout<<ans<<'\n';
}

int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	 T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}


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

#define MOD (1000000007)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double

void solve(){
   ll n,x,k;
   cin>>n>>x>>k;
   ll a[n];
   for(int i=0;i<n;i++){
     cin>>a[i];
   }
   sort(a,a+n);
   ll ans=0;
   for(int i=0;i<n;i++){
     ll tk = k;
     if(a[i]%x==0) tk--;
     ll l = x*tk+a[i];
     ll r = x*(tk+1)+a[i];
     r--;
     //cout<<l<<" "<<r<<'\n';
     auto li = lower_bound(a,a+n,l);
     auto ri = lower_bound(a,a+n,r);
     if(*ri>r || ri==a+n) ri--;
     //cout<<*li<<" "<<*ri<<" "<<(ri-li+1)<<'\n';
     ans+=max(0,(int)(ri-li+1));
   }
   cout<<ans<<'\n';
}

int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	 T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}


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

#define MOD (1000000007)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double

void solve(){
   ll n,x,k;
   cin>>n>>x>>k;
   ll a[n];
   for(int i=0;i<n;i++){
     cin>>a[i];
   }
   sort(a,a+n);
   ll ans=0;
   for(int i=0;i<n;i++){
     ll tk = k;
     if(a[i]%x==0) tk--;
     ll l = x*tk+a[i];
     l-=(l)%x;
     ll r =l+x;
     r--;
     //cout<<l<<" "<<r<<'\n';
     auto li = lower_bound(a,a+n,l);
     auto ri = upper_bound(a,a+n,r);
     if(ri==a+n || *ri>r) ri--;
     if(li!=a+n && ri>=a) {
      //cout<<*li<<" "<<*ri<<" "<<(ri-li+1)<<'\n';
      ans+=max(0,(int)(ri-li+1));
     }
   }
   cout<<ans<<'\n';
}

int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	 T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(2e5 + 5)
#define MAXM (int)(1e2+5)
#define fr first
#define sd second
#define MP make_pair
#define pb push_back
#define SZ(A) (int)A.size()
#define ALL(v) v.begin(), v.end()
#define M0(a) memset(a, 0, sizeof(a))
#define M1(a) memset(a, -1, sizeof(a))
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REPN(i,n,m) for(int i = m; i <= int(n); i++)
#define RREP(i,n) for(int i = int(n-1); i >= 0; i--)
#define RREPN(i, n, m) for(int i = n; i >= (int)m; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const ll INF= ll(1e15);
const ll MOD = 998'244'353;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> ppii;
template<typename T, typename U> inline void AMIN(T &x, U y){ if(x > y) x = y;}
template<typename T, typename U> inline void AMAX(T &x, U y){ if(x < y) x = y;}

int calc(int st, int ed, int X, vector<int> V) {

        if(ed >= V.size())
                return -1;

        int A = (V[st] - 1) / X ;
        int B = V[ed] / X;
        return B - A ;
}

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int N, X, K;
        cin >> N >> X >> K;

        vector<int> V(N, 0);
        for(int &x : V)
                cin >> x;

        sort(ALL(V));
        int st = 0, ed = 0;
        ll ans = 0;

        while(st < V.size()) {

                while(st > ed)
                        ed++;

                while(ed < V.size() && calc(st, ed, X, V) < K)
                        ed++;

                if(calc(st, ed, X, V) > K)
                        continue;

                int LL = ed, RR = V.size(), MM;
                while(LL < RR) {

                        MM = (LL + RR) >> 1;

                        if(V[MM] == V[ed])
                                LL = MM + 1;
                        else
                                RR = MM;
                }

                LL--;
                int num = 0;
                if(calc(st, ed, X, V) == K)
                        num = LL - ed + 1;

                if(V[st] == V[ed])
                        ans += 1LL * (num + num - 1);
                else
                        ans += 1LL * num;

                st++;
        }

        cout << ans << endl;
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(2e5 + 5)
#define MAXM (int)(1e2+5)
#define fr first
#define sd second
#define MP make_pair
#define pb push_back
#define SZ(A) (int)A.size()
#define ALL(v) v.begin(), v.end()
#define M0(a) memset(a, 0, sizeof(a))
#define M1(a) memset(a, -1, sizeof(a))
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REPN(i,n,m) for(int i = m; i <= int(n); i++)
#define RREP(i,n) for(int i = int(n-1); i >= 0; i--)
#define RREPN(i, n, m) for(int i = n; i >= (int)m; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const ll INF= ll(1e15);
const ll MOD = 998'244'353;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> ppii;
template<typename T, typename U> inline void AMIN(T &x, U y){ if(x > y) x = y;}
template<typename T, typename U> inline void AMAX(T &x, U y){ if(x < y) x = y;}

int calc(int st, int ed, int X, vector<int> V) {

        if(ed >= V.size())
                return -1;

        int A = (V[st] - 1) / X ;
        int B = V[ed] / X;
        return B - A ;
}

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int N, X, K;
        cin >> N >> X >> K;

        vector<int> V(N, 0);
        for(int &x : V)
                cin >> x;

        sort(ALL(V));
        int st = 0, ed = 0;
        ll ans = 0;

        while(ed < V.size()) {

                while(ed < V.size() && calc(st, ed, X, V) < K)
                        ed++;

                int num = 0;

                while(ed < V.size() && calc(st, ed, X, V) == K) {

                        num++, ed++;
                }

                if(V[st] == V[ed - 1])
                        ans += 1LL * num * num;
                else
                        ans += 1LL * num;
                st++;
        }

        cout << ans << endl;
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(2e5 + 5)
#define MAXM (int)(1e2+5)
#define fr first
#define sd second
#define MP make_pair
#define pb push_back
#define SZ(A) (int)A.size()
#define ALL(v) v.begin(), v.end()
#define M0(a) memset(a, 0, sizeof(a))
#define M1(a) memset(a, -1, sizeof(a))
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REPN(i,n,m) for(int i = m; i <= int(n); i++)
#define RREP(i,n) for(int i = int(n-1); i >= 0; i--)
#define RREPN(i, n, m) for(int i = n; i >= (int)m; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const ll INF= ll(1e15);
const ll MOD = 998'244'353;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> ppii;
template<typename T, typename U> inline void AMIN(T &x, U y){ if(x > y) x = y;}
template<typename T, typename U> inline void AMAX(T &x, U y){ if(x < y) x = y;}

int calc(int st, int ed, int X, vector<int> V) {

        if(ed >= V.size())
                return -1;

        int A = (V[st] - 1) / X ;
        int B = V[ed] / X;
        return B - A ;
}

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int N, X, K;
        cin >> N >> X >> K;

        vector<int> V(N, 0);
        for(int &x : V)
                cin >> x;

        sort(ALL(V));
        int st = 0, ed = 0;
        ll ans = 0;

        while(st < V.size()) {

                while(st > ed)
                        ed++;

                while(ed < V.size() && calc(st, ed, X, V) < K)
                        ed++;

                if(calc(st, ed, X, V) > K) {

                        st++;
                        continue;
                }

                int LL = ed, RR = V.size(), MM;
                while(LL < RR) {

                        MM = (LL + RR) >> 1;

                        if(V[MM] == V[ed])
                                LL = MM + 1;
                        else
                                RR = MM;
                }

                LL--;
                int num = 0;
                if(calc(st, ed, X, V) == K)
                        num = LL - ed + 1;

                if(V[st] == V[ed])
                        ans += 1LL * (num + num - 1);
                else
                        ans += 1LL * num;

                st++;
        }

        cout << ans << endl;
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(2e5 + 5)
#define MAXM (int)(1e2+5)
#define fr first
#define sd second
#define MP make_pair
#define pb push_back
#define SZ(A) (int)A.size()
#define ALL(v) v.begin(), v.end()
#define M0(a) memset(a, 0, sizeof(a))
#define M1(a) memset(a, -1, sizeof(a))
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REPN(i,n,m) for(int i = m; i <= int(n); i++)
#define RREP(i,n) for(int i = int(n-1); i >= 0; i--)
#define RREPN(i, n, m) for(int i = n; i >= (int)m; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const ll INF= ll(1e15);
const ll MOD = 998'244'353;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> ppii;
template<typename T, typename U> inline void AMIN(T &x, U y){ if(x > y) x = y;}
template<typename T, typename U> inline void AMAX(T &x, U y){ if(x < y) x = y;}

ll GS(ll val, ll K, ll X) {

        ll XX = (val + X - 1) / X;
        XX = X * XX;
        if(!K)
                return val;

        return XX + X * (K - 1);
}

ll GE(ll val, ll K, ll X) {

        ll XX = (val + X - 1) / X;
        XX = XX * X;
        return XX + X * K;
}

void RN(vector<ll> V, ll N, ll X, ll K, ll &ans) {

        ll st = 0, ed = 0;

        vector<pll> VP(N, {-1, -1});
        while(st < V.size()) {

                while(st > ed)
                        ed++;

                ll SV = GS(V[st], K, X);
                ll EV = GE(V[st], K, X);

                while(ed < V.size() && V[ed] < SV)
                        ed++;

                if(ed == V.size())
                        break;

                VP[st].fr = ed;

                ll LL = ed, RR = V.size(), MM;
                while(LL < RR) {

                        MM = (LL + RR) >> 1;

                        if(V[MM] < EV)
                                LL = MM + 1;
                        else
                                RR = MM;
                }
                VP[st].sd = LL - 1;
                st++;
        }

        REP(i, VP.size()) {

                st = VP[i].fr, ed = VP[i].sd;

                if(st == -1)
                        break;

                //cout << i << " " << st << " " << ed << endl;
                ll LL = st, RR = V.size(), MM;
                while(LL < RR) {

                        MM = (LL + RR) >> 1;

                        if(V[MM] == V[i])
                                LL = MM + 1;
                        else
                                RR = MM;
                }

                ll tot = ed - st + 1;
                ll sme = LL - st;
                ll oth = tot - sme;

                if(st == i)
                        ans += 2 * sme - 1 + oth;
                else
                        ans += tot;
        }
}

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll N, X, K;
        cin >> N >> X >> K;

        vector<ll> V(N, 0);
        for(ll &x : V)
                cin >> x;

        ll ans = 0;
        sort(ALL(V));
        RN(V, N, X, K, ans);

        cout << ans << endl;
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(1e5 + 5)
#define MAXM (int)(1e2+5)
#define fr first
#define sd second
#define MP make_pair
#define pb push_back
#define SZ(A) (int)A.size()
#define ALL(v) v.begin(), v.end()
#define M0(a) memset(a, 0, sizeof(a))
#define M1(a) memset(a, -1, sizeof(a))
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REPN(i,n,m) for(int i = m; i <= int(n); i++)
#define RREP(i,n) for(int i = int(n-1); i >= 0; i--)
#define RREPN(i, n, m) for(int i = n; i >= (int)m; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const ll INF= ll(1e15);
const ll MOD = 998'244'353;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> ppii;
template<typename T, typename U> inline void AMIN(T &x, U y){ if(x > y) x = y;}
template<typename T, typename U> inline void AMAX(T &x, U y){ if(x < y) x = y;}
ll LNK[MAXN];

ll GP(ll val, ll X, ll K) {

        ll XX = val / X + 1;
        XX = X * XX;
        return XX;
}

ll GS(ll val, ll X, ll K) {

        if(!K)
                return val;

        ll XX = (val + X - 1) / X;
        XX = X * XX;
        return XX + X * (K - 1);
}

void build(vector<ll> V, ll N, ll X, ll K) {

        ll st = 0, ed = 0;
        while(st < V.size()) {

                while(st > ed)
                        ed++;

                ll SV = GP(V[st], X, K);

                while(ed < V.size() && V[ed] < SV)
                        ed++;

                LNK[st] = ed;
                st++;
        }
}

ll GV(vector<ll> V, ll id) {

        ll LL = id, RR = V.size(), MM;
        while(LL < RR) {

                MM = (LL + RR) >> 1;

                if(V[MM] == V[id])
                        LL = MM + 1;
                else
                        RR = MM;
        }
        return LL - id - 1;
}

void calc(vector<ll> V, ll N, ll X, ll K, ll &ans) {

        ll st = 0, ed = 0;
        LNK[V.size()] = N;
        while(st < V.size()) {

                while(st > ed)
                        ed++;

                ll SV = GS(V[st], X, K);

                while(ed < V.size() && V[ed] < SV)
                        ed++;

                //cout << st << " " << SV << " " << ed << " " << LNK[ed] << endl;
                ans += LNK[ed] - ed;

                if(st == ed)
                        ans += GV(V, st);
                st++;
        }
}

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll N, X, K;
        cin >> N >> X >> K;

        vector<ll> V(N, 0);
        for(ll &x : V)
                cin >> x;

        sort(ALL(V));
        ll ans = 0;
        build(V, N, X, K);
        calc(V, N, X, K, ans);

        cout << ans << endl;
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(2e5 + 5)
#define MAXM (int)(1e2+5)
#define fr first
#define sd second
#define MP make_pair
#define pb push_back
#define SZ(A) (int)A.size()
#define ALL(v) v.begin(), v.end()
#define M0(a) memset(a, 0, sizeof(a))
#define M1(a) memset(a, -1, sizeof(a))
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REPN(i,n,m) for(int i = m; i <= int(n); i++)
#define RREP(i,n) for(int i = int(n-1); i >= 0; i--)
#define RREPN(i, n, m) for(int i = n; i >= (int)m; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const ll INF= ll(1e15);
const ll MOD = 998'244'353;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> ppii;
template<typename T, typename U> inline void AMIN(T &x, U y){ if(x > y) x = y;}
template<typename T, typename U> inline void AMAX(T &x, U y){ if(x < y) x = y;}

int calc(int st, int ed, int X, vector<int> V) {

        if(ed >= V.size())
                return -1;

        int A = (V[st] - 1) / X ;
        int B = V[ed] / X;
        return B - A ;
}

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int N, X, K;
        cin >> N >> X >> K;

        vector<int> V(N, 0);
        for(int &x : V)
                cin >> x;

        sort(ALL(V));
        int st = 0, ed = 0;
        ll ans = 0;

        while(st < V.size()) {

                while(st > ed)
                        ed++;

                while(ed < V.size() && calc(st, ed, X, V) < K)
                        ed++;

                int LL = ed, RR = V.size(), MM;
                while(LL < RR) {

                        MM = (LL + RR) >> 1;

                        if(calc(ed, MM, X, V) == K)
                                LL = MM + 1;
                        else
                                RR = MM;
                }

                LL--;
                int num = 0;
                if(calc(ed, LL, X, V) == K)
                        num = LL - ed + 1;

                if(V[ed] == V[LL])
                        ans += 1LL * (num + num - 1);
                else
                        ans += 1LL * num;

                st++;
        }

        cout << ans << endl;
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(1e5 + 5)
#define MAXM (int)(1e2+5)
#define fr first
#define sd second
#define MP make_pair
#define pb push_back
#define SZ(A) (int)A.size()
#define ALL(v) v.begin(), v.end()
#define M0(a) memset(a, 0, sizeof(a))
#define M1(a) memset(a, -1, sizeof(a))
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REPN(i,n,m) for(int i = m; i <= int(n); i++)
#define RREP(i,n) for(int i = int(n-1); i >= 0; i--)
#define RREPN(i, n, m) for(int i = n; i >= (int)m; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const ll INF= ll(1e15);
const ll MOD = 998'244'353;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> ppii;
template<typename T, typename U> inline void AMIN(T &x, U y){ if(x > y) x = y;}
template<typename T, typename U> inline void AMAX(T &x, U y){ if(x < y) x = y;}

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll N, X, K;
        cin >> N >> X >> K;

        vector<ll> V(N, 0);
        for(ll &x : V)
                cin >> x;

        sort(ALL(V));
        ll ans = 0;

        REP(i, N) {

                ll XX = (V[i] - 1) / X;
                ll LL = lower_bound(ALL(V), max(V[i], (XX + K) * X)) - V.begin();
                ll RR = lower_bound(ALL(V), max(V[i], (XX + K + 1) * X)) - V.begin();

                ans += RR - LL;
        }

        cout << ans << endl;
        return 0;
}


import java.util.*;

public class MishkaandGame {

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int testcase=sc.nextInt();
        int mish=0;
        int chris=0;
        for(int i=0;i<testcase;i++){

            int a=sc.nextInt();
            int b=sc.nextInt();
            if(a>b){
                mish++;
            }
            if(b>a){
                chris++;
            }

        }
        if(mish==chris){
            System.out.println("Friendship is magic!^^");
        }
        else if(mish>chris){
            System.out.println("Mishka");
        }
        else{
            System.out.println("Chris");
        }
    }

}


// package com.company;

import  java.util.*;
public class A703 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < n ; i++) {
            int  mishka = in.nextInt(); int chris = in.nextInt();
            if (mishka > chris){
                sum1++;
            }
            else
                sum2++;
        }
        System.out.println(sum1 > sum2 ? "Mishka" : sum1 == sum2 ? "Friendship is magic!^^" : "Chris");
    }
}


import  java.util.*;
public class A703 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < n ; i++) {
            int  mishka = in.nextInt(); int chris = in.nextInt();
            if (mishka > chris){
                sum1 ++;
            }
            else if(mishka < chris) {
                sum2++;
            }
        }
        if (sum1 > sum2){
            System.out.println("Mishka");
        }
        else  if( sum1 == sum2)
        {
            System.out.println("Friendship is magic!^^\n");
        }
        else {
            System.out.println("Chris");
        }
    }
}


import java.util.Scanner;

public class Codeforces703A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int chris = 0 ; int Mishka =0 ;
		for(int i = 0 ; i < n ; i++) {
			int a = sc.nextInt() ; int b = sc.nextInt();
			if(a > b)Mishka++;
			if(b  > a)chris++;
		}
		if(Mishka > chris) {
			System.out.println("Mishka");
		}else if(chris > Mishka) {
			System.out.println("Chris");
		}else System.out.println("Friendship is magic!^^");

		sc.close();
	}

}


import java.util.Scanner;

public class A703 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int count_m = 0;
        int count_c = 0;
        for(int i = 0; i < t; i++){
            int m = sc.nextInt();
            int c = sc.nextInt();
            if(m > c) count_m++;
            if(c > m) count_c++;
        }
        if(count_m > count_c){
            System.out.println("Mishka");
        }else if(count_c > count_m){
            System.out.println("Chris");
        }else{
            System.out.println("Friendship is magic!^^");
        }
    }
}


import java.io.*;
import java.util.*;
import java.util.stream.IntStream;

import static java.lang.Math.*;
import static java.util.Arrays.*;

@SuppressWarnings("ALL")
public class MishkaandGame {
    public static void main(String[] $) throws IOException {
        MishkaandGame o = new MishkaandGame();
        o.main();
        out.flush();
        out.close();
    }

    void main() throws IOException {
        int T = in.ri();
        int M = 0, C = 0;
        while (T-- > 0) {
            int a, b;
            in.r();
            a = in.ni();
            b = in.ni();
            if(a>b) M++;
            else if(a<b) C++;
        }
       // out.prln(M+" "+C);
        if (M > C) out.prln("Mishka");
        else if (M < C) out.prln("Chris");
        else if(M==C) out.prln("Friendship is magic!^^");
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();
    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;

    //Fast Reader Class
    /*static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }*/

    //Input fxs
    static class in {
        // input
        static void r() throws IOException {
            input = new StringTokenizer(rline());
        }

        static int ri() throws IOException {
            return Integer.parseInt(rline());
        }

        static long rl() throws IOException {
            return Long.parseLong(rline());
        }

        static double rd() throws IOException {
            return Double.parseDouble(rline());
        }

        static int[] ria(int n) throws IOException {
            int[] a = new int[n];
            r();
            for (int i = 0; i < n; ++i) a[i] = ni();
            return a;
        }

        static int[] riam1(int n) throws IOException {
            int[] a = new int[n];
            r();
            for (int i = 0; i < n; ++i) a[i] = ni() - 1;
            return a;
        }

        static long[] ria1i(long n) throws IOException {
            long[] a = new long[(int) n + 1];
            r();
            for (int i = 1; i <= n; i++) a[i] = nl();
            return a;
        }

        static long[] rla(int n) throws IOException {
            long[] a = new long[n];
            r();
            for (int i = 0; i < n; ++i) a[i] = nl();
            return a;
        }

        static double[] rda(int n) throws IOException {
            double[] a = new double[n];
            r();
            for (int i = 0; i < n; ++i) a[i] = nd();
            return a;
        }

        static char[] rcha() throws IOException {
            return rline().toCharArray();
        }

        static ArrayList<Integer> riaa(int n) throws IOException {
            ArrayList<Integer> a = new ArrayList<>();
            r();
            for (int i = 0; i < n; i++) a.add(ni());
            return a;
        }

        static String rline() throws IOException {
            return __in.readLine();
        }

        static String n() {
            return input.nextToken();
        }

        static int rni() throws IOException {
            r();
            return ni();
        }

        static int ni() {
            return Integer.parseInt(n());
        }

        static long rnl() throws IOException {
            r();
            return nl();
        }

        static long nl() {
            return Long.parseLong(n());
        }

        static double rnd() throws IOException {
            r();
            return nd();
        }

        static double nd() {
            return Double.parseDouble(n());
        }

        static List<List<Integer>> rg(int n, int m) throws IOException {
            List<List<Integer>> g = GR.g(n);
            for (int i = 0; i < m; ++i) GR.c(g, rni() - 1, ni() - 1);
            return g;
        }

        static void rg(List<List<Integer>> g, int m) throws IOException {
            for (int i = 0; i < m; ++i) GR.c(g, rni() - 1, ni() - 1);
        }

        static List<List<Integer>> rdg(int n, int m) throws IOException {
            List<List<Integer>> g = GR.g(n);
            for (int i = 0; i < m; ++i) GR.cto(g, rni() - 1, ni() - 1);
            return g;
        }

        static void rdg(List<List<Integer>> g, int m) throws IOException {
            for (int i = 0; i < m; ++i) GR.cto(g, rni() - 1, ni() - 1);
        }

        static List<Set<Integer>> rsg(int n, int m) throws IOException {
            List<Set<Integer>> g = GR.sg(n);
            for (int i = 0; i < m; ++i) GR.c(g, rni() - 1, ni() - 1);
            return g;
        }

        static void rsg(List<Set<Integer>> g, int m) throws IOException {
            for (int i = 0; i < m; ++i) GR.c(g, rni() - 1, ni() - 1);
        }

        static List<Set<Integer>> rdsg(int n, int m) throws IOException {
            List<Set<Integer>> g = GR.sg(n);
            for (int i = 0; i < m; ++i) GR.cto(g, rni() - 1, ni() - 1);
            return g;
        }

        static void rdsg(List<Set<Integer>> g, int m) throws IOException {
            for (int i = 0; i < m; ++i) GR.cto(g, rni() - 1, ni() - 1);
        }

        static int[][] rim(int n, int m) throws IOException {
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                in.r();
                for (int j = 0; j < m; j++) {
                    a[i][j] = in.ni();
                }
            }
            return a;
        }
    }

    //Output fxs
    static class out {
        // output
        static void pr(int i) {
            __out.print(i);
        }

        static void prln(int i) {
            __out.println(i);
        }

        static void pr(long l) {
            __out.print(l);
        }

        static void prln(long l) {
            __out.println(l);
        }

        static void pr(double d) {
            __out.print(d);
        }

        static void prln(double d) {
            __out.println(d);
        }

        static void pr(char c) {
            __out.print(c);
        }

        static void prln(char c) {
            __out.println(c);
        }

        static void pr(char[] s) {
            __out.print(new String(s));
        }

        static void prln(char[] s) {
            __out.println(new String(s));
        }

        static void pr(String s) {
            __out.print(s);
        }

        static void prln(String s) {
            __out.println(s);
        }

        static void pr(Object o) {
            __out.print(o);
        }

        static void prln(Object o) {
            __out.println(o);
        }

        static void prln() {
            __out.println();
        }

        static void pryes() {
            prln("yes");
        }

        static void pry() {
            prln("Yes");
        }

        static void prY() {
            prln("YES");
        }

        static void prno() {
            prln("no");
        }

        static void prn() {
            prln("No");
        }

        static void prN() {
            prln("NO");
        }

        static void pryesno(boolean b) {
            prln(b ? "yes" : "no");
        }

        ;

        static void pryn(boolean b) {
            prln(b ? "Yes" : "No");
        }

        static void prYN(boolean b) {
            prln(b ? "YES" : "NO");
        }

        static void prln(int... a) {
            for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i) ;
            if (a.length > 0) prln(a[a.length - 1]);
            else prln();
        }

        static void prln(long... a) {
            for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i) ;
            if (a.length > 0) prln(a[a.length - 1]);
            else prln();
        }

        static void prln(double... a) {
            for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i) ;
            if (a.length > 0) prln(a[a.length - 1]);
            else prln();
        }

        static <T> void prln(Collection<T> c) {
            int n = c.size() - 1;
            Iterator<T> iter = c.iterator();
            for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i) ;
            if (n >= 0) prln(iter.next());
            else prln();
        }

        static void h() {
            prln("hlfd");
            flush();
        }

        static void flush() {
            __out.flush();
        }

        static void close() {
            __out.close();
        }

        static void prM(int[][] a, int n, int m) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++)
                    out.pr(a[i][j] + " ");
                out.prln();
            }
        }
    }

    //Math fxs
    static class mathx {
        // math util
        static int minof(int a, int b, int c) {
            return min(a, min(b, c));
        }

        static int minof(int... x) {
            if (x.length == 1) return x[0];
            if (x.length == 2) return min(x[0], x[1]);
            if (x.length == 3) return min(x[0], min(x[1], x[2]));
            int min = x[0];
            for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i];
            return min;
        }

        static long minof(long a, long b, long c) {
            return min(a, min(b, c));
        }

        static long minof(long... x) {
            if (x.length == 1) return x[0];
            if (x.length == 2) return min(x[0], x[1]);
            if (x.length == 3) return min(x[0], min(x[1], x[2]));
            long min = x[0];
            for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i];
            return min;
        }

        static int maxof(int a, int b, int c) {
            return max(a, max(b, c));
        }

        static int maxof(int... x) {
            if (x.length == 1) return x[0];
            if (x.length == 2) return max(x[0], x[1]);
            if (x.length == 3) return max(x[0], max(x[1], x[2]));
            int max = x[0];
            for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i];
            return max;
        }

        static long maxof(long a, long b, long c) {
            return max(a, max(b, c));
        }

        static long maxof(long... x) {
            if (x.length == 1) return x[0];
            if (x.length == 2) return max(x[0], x[1]);
            if (x.length == 3) return max(x[0], max(x[1], x[2]));
            long max = x[0];
            for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i];
            return max;
        }

        static int powi(int a, int b) {
            if (a == 0) return 0;
            int ans = 1;
            while (b > 0) {
                if ((b & 1) > 0) ans *= a;
                a *= a;
                b >>= 1;
            }
            return ans;
        }

        static long powl(long a, int b) {
            if (a == 0) return 0;
            long ans = 1;
            while (b > 0) {
                if ((b & 1) > 0) ans *= a;
                a *= a;
                b >>= 1;
            }
            return ans;
        }

        static int fli(double d) {
            return (int) d;
        }

        static int cei(double d) {
            return (int) ceil(d);
        }

        static long fll(double d) {
            return (long) d;
        }

        static long cel(double d) {
            return (long) ceil(d);
        }

        static int gcf(int a, int b) {
            return b == 0 ? a : gcf(b, a % b);
        }

        static long gcf(long a, long b) {
            return b == 0 ? a : gcf(b, a % b);
        }

        static int lcm(int a, int b) {
            return a * b / gcf(a, b);
        }

        static long lcm(long a, long b) {
            return a * b / gcf(a, b);
        }

        static int randInt(int min, int max) {
            return __rand.nextInt(max - min + 1) + min;
        }

        static long mix(long x) {
            x += 0x9e3779b97f4a7c15L;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L;
            x = (x ^ (x >> 27)) * 0x94d049bb133111ebL;
            return x ^ (x >> 31);
        }
    }

    //Array fxs
    static class ARR {
        // array util
        static void reverse(int[] a) {
            for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
                int swap = a[i];
                a[i] = a[n - i - 1];
                a[n - i - 1] = swap;
            }
        }

        static void reverse(long[] a) {
            for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
                long swap = a[i];
                a[i] = a[n - i - 1];
                a[n - i - 1] = swap;
            }
        }

        static void reverse(double[] a) {
            for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
                double swap = a[i];
                a[i] = a[n - i - 1];
                a[n - i - 1] = swap;
            }
        }

        static void reverse(char[] a) {
            for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
                char swap = a[i];
                a[i] = a[n - i - 1];
                a[n - i - 1] = swap;
            }
        }

        static void shuffle(int[] a) {
            int n = a.length - 1;
            for (int i = 0; i < n; ++i) {
                int ind = mathx.randInt(i, n);
                int swap = a[i];
                a[i] = a[ind];
                a[ind] = swap;
            }
        }

        static void shuffle(long[] a) {
            int n = a.length - 1;
            for (int i = 0; i < n; ++i) {
                int ind = mathx.randInt(i, n);
                long swap = a[i];
                a[i] = a[ind];
                a[ind] = swap;
            }
        }

        static void shuffle(double[] a) {
            int n = a.length - 1;
            for (int i = 0; i < n; ++i) {
                int ind = mathx.randInt(i, n);
                double swap = a[i];
                a[i] = a[ind];
                a[ind] = swap;
            }
        }

        static void rsort(int[] a) {
            shuffle(a);
            sort(a);
        }

        static void rsort(long[] a) {
            shuffle(a);
            sort(a);
        }

        static void rsort(double[] a) {
            shuffle(a);
            sort(a);
        }

        static int[] copy(int[] a) {
            int[] ans = new int[a.length];
            System.arraycopy(a, 0, ans, 0, a.length);
            return ans;
        }

        static long[] copy(long[] a) {
            long[] ans = new long[a.length];
            System.arraycopy(a, 0, ans, 0, a.length);
            return ans;
        }

        static double[] copy(double[] a) {
            double[] ans = new double[a.length];
            System.arraycopy(a, 0, ans, 0, a.length);
            return ans;
        }

        static char[] copy(char[] a) {
            char[] ans = new char[a.length];
            System.arraycopy(a, 0, ans, 0, a.length);
            return ans;
        }
    }

    //Graph fxs
    static class GR {
        // graph util
        static List<List<Integer>> g(int n) {
            List<List<Integer>> g = new ArrayList<>();
            for (int i = 0; i < n; ++i) g.add(new ArrayList<>());
            return g;
        }

        static List<Set<Integer>> sg(int n) {
            List<Set<Integer>> g = new ArrayList<>();
            for (int i = 0; i < n; ++i) g.add(new HashSet<>());
            return g;
        }

        static void c(List<? extends Collection<Integer>> g, int u, int v) {
            g.get(u).add(v);
            g.get(v).add(u);
        }

        static void cto(List<? extends Collection<Integer>> g, int u, int v) {
            g.get(u).add(v);
        }

        static void dc(List<? extends Collection<Integer>> g, int u, int v) {
            g.get(u).remove(v);
            g.get(v).remove(u);
        }

        static void dcto(List<? extends Collection<Integer>> g, int u, int v) {
            g.get(u).remove(v);
        }
    }

    //Utilsx class
    static class utilX {
        static int[] subsetSum(int[] nums) {
            int M = IntStream.of(nums).sum();
            int[] m = new int[M + 10];
            for (int i = 0; i < M + 10; i++) m[i] = 0;
            m[0] = 1;
            for (int num : nums) {
                for (int j = M; j >= num; j--) {
                    m[j] |= m[j - num];
                }
            }
            return m;
        }

        static int LIS(int[] nums) {
            int[] m = new int[nums.length];
            for (int i = nums.length - 1; i >= 0; i--) {
                m[i] = 1;
                for (int j = i + 1; j < nums.length; j++) {
                    if (nums[j] > nums[i]) {
                        m[i] = max(m[i], m[j] + 1);
                    }
                }
            }
            int ans = 0;
            for (int i = 0; i < nums.length; i++) {
                ans = max(ans, m[i]);
            }
            return ans;
        }
    }

    //Pair Class
    static class Pair<F, S> {
        public final F first;
        public final S second;

        public Pair(F first, S second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof Pair)) {
                return false;
            }
            Pair<?, ?> p = (Pair<?, ?>) o;
            return Objects.equals(p.first, first) && Objects.equals(p.second, second);
        }
    }
}