#include <bits/stdc++.h>

using namespace std;
int a[100009];
int main()
{
    vector<int>v,vv;
int n,cnt=0,maxi=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<n;i++){
    if(v.empty()||v.back()!=a[i]){
        v.push_back(a[i]);
        cnt++;
        vv.push_back(cnt);
    }
    else{
        v.pop_back();
        cnt--;
        vv.push_back(cnt);
    }
}
for(int i=0;i<vv.size();i++){
    maxi=max(maxi,vv[i]);
}
cout<<maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100009];
int main()
{
    vector<int>v,vv;
int n,cnt=0,maxi=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<2*n;i++){
    if(v.empty()||v.back()!=a[i]){
        v.push_back(a[i]);
        cnt++;
        vv.push_back(cnt);
    }
    else{
        v.pop_back();
        cnt--;
        vv.push_back(cnt);
    }
}
for(int i=0;i<vv.size();i++){
    maxi=max(maxi,vv[i]);
}
cout<<maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[1000009];
int main()
{
    vector<int>v,vv;
long long n,cnt=0,maxi=0;
cin>>n;
for(long long i=0;i<n;i++){
    cin>>a[i];
}
for(long long i=0;i<n;i++){
    if(v.empty()||v.back()!=a[i]){
        v.push_back(a[i]);
        cnt++;
        vv.push_back(cnt);
    }
    else{
        v.pop_back();
        cnt--;
        vv.push_back(cnt);
    }
}
for(long long i=0;i<vv.size();i++){
    maxi=max(maxi,vv[i]);
}
cout<<maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long a[1000009];
int main()
{
    vector<long long>v,vv;
long long n,cnt=0,maxi=0;
cin>>n;
for(long long i=0;i<n;i++){
    cin>>a[i];
}
for(long long i=0;i<n;i++){
    if(v.empty()||v.back()!=a[i]){
        v.push_back(a[i]);
        cnt++;
        vv.push_back(cnt);
    }
    else{
        v.pop_back();
        cnt--;
        vv.push_back(cnt);
    }
}
for(long long i=0;i<vv.size();i++){
    maxi=max(maxi,vv[i]);
}
cout<<maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long a[1000000],f[1000000];
int main()
{
    vector<int>v,vv;
long long n,cnt=0,maxi=0,m,maxi1=0;
cin>>n;
for(long long i=0;i<n;i++){
    cin>>a[i];
    maxi1=max(maxi1,a[i]);

}
for(long long i=0;i<maxi1;i++){
    f[a[i]]++;
    if(f[a[i]]==2)
        cnt--;
    else
        cnt++;
    maxi=max(maxi,cnt);
}
cout<<maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100009],f[100009];
int main()
{
    vector<int>v,vv;
int n,cnt=0,maxi=0,m,maxi1=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
    maxi1=max(maxi1,a[i]);

}
for(int i=0;i<maxi1;i++){
    f[a[i]]++;
    if(f[a[i]]==2)
        cnt--;
    else
        cnt++;
    maxi=max(maxi,cnt);
}
cout<<maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int f[100009];
int main()
{
    vector<int>v,vv;
int n,cnt=0,maxi=0,a,maxi1=0;
cin>>n;
for(int i=0;i<2*n;i++){
    cin>>a;
    f[a]++;
    if(f[a]==2)
        cnt--;
    else
        cnt++;
    maxi=max(maxi,cnt);
}

cout<<maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100009],f[100009];
int main()
{
    vector<int>v,vv;
int n,cnt=0,maxi=0,m,maxi1=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
    maxi1=max(maxi1,a[i]);

}
for(int i=0;i<maxi1;i++){
    f[a[i]]++;
    if(f[a[i]]!=2)
        cnt++;
    else
        cnt--;
    maxi=max(maxi,cnt);
}
cout<<maxi;
    return 0;
}


#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int s[n];
    int m = 0;

    for(int i=0; i<n; i++){
        s[i] = 0;
    }

    for(int i=0; i<2*n; i++){
        int x;
        cin >> x;

        if(s[x-1] != 0){
            m -= 1;
        }else{
            s[x-1] = 1;
            m += 1;
        }

        if(m > ans){
            ans = m;
        }
    }
    cout << ans;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> s;

    for(int i=0; i<2*n; i++){
        int x;
        cin >> x;

        bool b = false;
        for(int y=0; y<s.size(); y++){
            if(s[y] == x){
                s.erase(s.begin()+y);
                b = true;
                break;
            }
        }
        if(!b){
            s.push_back(x);
        }

        if(s.size() > ans){
            ans = s.size();
        }
    }
    cout << ans;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int m = 0;
    vector<int> s;

    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        if(count(s.begin(), s.end(), x) != 0){
            m -= 1;
        }else{
            m += 1;
        }
        if(m > ans){
            ans = m;
        }
        s.push_back(x);
    }
    cout << ans;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int m = 0;
    vector<int> s;

    for(int i=0; i<2*n; i++){
        int x;
        cin >> x;
        if(count(s.begin(), s.end(), x) != 0){
            m -= 1;
        }else{
            m += 1;
            s.push_back(x);
        }
        if(m > ans){
            ans = m;
        }
    }
    cout << ans;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> s;

    for(int i=0; i<2*n; i++){
        int x;
        cin >> x;

        bool b = false;
        for(int y=0; y<s.size(); y++){
            if(s[y] == x){
                s.erase(s.begin()+y);
                b = true;
                break;
            }
        }
        if(!b){
            s.push_back(x);
        }

        if(s.size() > ans){
            ans = s.size();
        }
    }
    cout << ans;
}


// In the name of God
#include<bits/stdc++.h>
using namespace std;

int n;

int main() {
	set<int> s;
	cin >> n;
	int ans = 1;
	while (n--) {
		int x;
		cin >> x;
		if (s.count(x))
			s.erase(x);
		else
			s.insert(x);
		int y = s.size();
		ans = max(ans, y);
	}
	cout << ans << endl;
	return 0;
}


// In the name of God
#include<bits/stdc++.h>
using namespace std;

int n;

int main() {
	set<int> s;
	cin >> n;
	int ans = 1;
	while (n--) {
		int x;
		cin >> x;
		if (s.count(x))
			s.erase(x);
		else
			s.insert(x);
		int y = s.size();
		ans = max(ans, y);
	}
	int y = s.size();
	cout << max(ans, y)<< endl;
	return 0;
}


// In the name of God
#include<bits/stdc++.h>
using namespace std;

const int N = 1000 * 100 + 3;
int n;
bool mark[N];

int main() {
	cin >> n;
	int ans = 1, m = 0;
	n *= 2;
	while (n--) {
		int x;
		cin >> x;
		if (!mark[x])
			mark[x] = true, m++;
		else
			mark[x] = false, m--;
		ans = max(ans, m);
	}
	cout << max(ans, m)<< endl;
	return 0;
}


// In the name of God
#include<bits/stdc++.h>
using namespace std;

const int N = 1000 * 100 + 3;
int n;
bool mark[N];

int main() {
	cin >> n;
	int ans = 1, m = 0;
	while (n--) {
		int x;
		cin >> x;
		if (!mark[x])
			mark[x] = true, m++;
		else
			mark[x] = false, m--;
		ans = max(ans, m);
	}
	cout << max(ans, m)<< endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll modularExponentiation(ll x,ll n,ll M){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modularExponentiation((x*x)%M,n/2,M);
    return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;
}
ll binaryExponentiation(ll x,ll n){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return binaryExponentiation(x*x,n/2);
    else
        return x*binaryExponentiation(x*x,(n-1)/2);
}
ll GCD(ll A, ll B){
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll modPrimeInverse(ll A,ll M){
    return modularExponentiation(A,M-2,M);
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    ll a[2*n];
    unordered_map<ll, ll> m;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        m[a[i]] = 0;
    }
    ll table = 0;
    ll ans = 0;
    for(ll i=0;i<n;i++){
        if(m[a[i]] == 0){
            table++;
            ans = max(ans, table);
            m[a[i]] = 1;
        }
        else if(m[a[i]] == 1){
            table--;
            m[a[i]] = 0;
        }
    }
    cout << ans << "\n";

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


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll modularExponentiation(ll x,ll n,ll M){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modularExponentiation((x*x)%M,n/2,M);
    return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;
}
ll binaryExponentiation(ll x,ll n){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return binaryExponentiation(x*x,n/2);
    else
        return x*binaryExponentiation(x*x,(n-1)/2);
}
ll GCD(ll A, ll B){
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll modPrimeInverse(ll A,ll M){
    return modularExponentiation(A,M-2,M);
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    ll a[n];
    map<ll, ll> m;
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll table = 0;
    ll ans = 0;
    for(ll i=0;i<n;i++){
        if(m[a[i]] == 0){
            table++;
            ans = max(ans, table);
            m[a[i]] = 1;
        }
        else if(m[a[i]] == 1){
            table--;
            // m[a[i]] = 0;
        }
    }
    cout << ans << "\n";

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


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll modularExponentiation(ll x,ll n,ll M){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modularExponentiation((x*x)%M,n/2,M);
    return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;
}
ll binaryExponentiation(ll x,ll n){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return binaryExponentiation(x*x,n/2);
    else
        return x*binaryExponentiation(x*x,(n-1)/2);
}
ll GCD(ll A, ll B){
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll modPrimeInverse(ll A,ll M){
    return modularExponentiation(A,M-2,M);
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    ll a[2*n];
    unordered_map<ll, ll> m;
    for(ll i=0;i<2*n;i++){
        cin >> a[i];
        m[a[i]] = 0;
    }
    ll table = 0;
    ll ans = 0;
    for(ll i=0;i<2*n;i++){
        if(m[a[i]] == 0){
            table++;
            ans = max(ans, table);
            m[a[i]] = 1;
        }
        else if(m[a[i]] == 1){
            table--;
            m[a[i]] = 0;
        }
    }
    cout << ans << "\n";

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


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll modularExponentiation(ll x,ll n,ll M){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modularExponentiation((x*x)%M,n/2,M);
    return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;
}
ll binaryExponentiation(ll x,ll n){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return binaryExponentiation(x*x,n/2);
    else
        return x*binaryExponentiation(x*x,(n-1)/2);
}
ll GCD(ll A, ll B){
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll modPrimeInverse(ll A,ll M){
    return modularExponentiation(A,M-2,M);
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    ll a[2*n];
    unordered_map<ll, ll> m;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        m[a[i]] = 0;
    }
    ll table = 0;
    ll ans = 0;
    for(ll i=0;i<2*n;i++){
        if(m[a[i]] == 0){
            table++;
            ans = max(ans, table);
            m[a[i]] = 1;
        }
        else if(m[a[i]] == 1){
            table--;
            m[a[i]] = 0;
        }
    }
    cout << ans << "\n";

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


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll modularExponentiation(ll x,ll n,ll M){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modularExponentiation((x*x)%M,n/2,M);
    return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;
}
ll binaryExponentiation(ll x,ll n){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return binaryExponentiation(x*x,n/2);
    else
        return x*binaryExponentiation(x*x,(n-1)/2);
}
ll GCD(ll A, ll B){
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll modPrimeInverse(ll A,ll M){
    return modularExponentiation(A,M-2,M);
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    ll a[n];
    unordered_map<ll, ll> m;
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll table = 0;
    ll ans = 0;
    for(ll i=0;i<n;i++){
        if(m[a[i]] == 0){
            table++;
            ans = max(ans, table);
            m[a[i]] = 1;
        }
        else if(m[a[i]] == 1){
            table--;
            m[a[i]] = 0;
        }
    }
    cout << ans << "\n";

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


#include <bits/stdc++.h>

using namespace std;

long long n,i,m,c,maxx,j,v;

long long a[10007];

int main()
{
    maxx=0;
    cin>>n;
    v=n*2;
    for(i=0;i<v;i++){
        cin>>m;
        a[m]++;
        c=0;
        for(j=1;j<=n;j++)
            if(a[j]==1)
                c++;
        if(c>maxx)
            maxx=c;
   }
    cout<<maxx;
    return 0;
}


n, m, k = map(int,input().split())
vls = list(map(int,input().split()))
vls.sort()
if vls[-1] == vls[-2]:
    print(max(vls)*m)
else:
   print((vls[-1]*k+vls[-2])*(m//(k+1)))


n, m, k = map(int,input().split())
vls = list(map(int,input().split()))
vls.sort()
if vls[-1] == vls[-2]:
    print(max(vls)*m)
else:
   print((vls[-1]*k+vls[-2])*(m//(k+1)) + ((m%(k+1)) * vls[-1]))


import math
n , m , k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
mx1 = l[-1]
mx2 = l[-2]
print(math.floor(m / (k + 1) * (mx1 * k + mx2)+(m % (k + 1)) * mx1))
#kalay))
#⌊mk+1⌋⋅(x⋅k+y)+(m%(k+1))⋅x


import math
n , m , k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
mx1 = l[-1]
mx2 = l[-2]
print(math.floor(m / (k + 1)) * (mx1 * k + mx2)+(m % (k + 1)) * mx1)
#kalay))
#⌊mk+1⌋⋅(x⋅k+y)+(m%(k+1))⋅x


n,m,k=map(int,input().split())
l=list(map(int,input().split()))
y=max(l)
l.remove(y)
z=max(l)
a=m%(k+1)
if(a==0):
	h=m//(k+1)
	print((y*k+z)*h)
else:
	r=m//(k+1)
	l=(k+1)*r
	o=(m-l)*z
	print((y*k+z)*r+o)


n,m,k=map(int,input().split())
l=list(map(int,input().split()))
y=max(l)
l.remove(y)
z=max(l)
a=m%(k+1)
if(a==0):
	h=m//(k+1)
	print((y*k+z)*h)
else:
	r=m//(k+1)
	l=(k+1)*r
	o=(m-l)*z
	print((y*k+z)*r+o+1+r)


n,m,k=map(int,input().split())
l=list(map(int,input().split()))
y=max(l)
l.remove(y)
z=max(l)
a=m%(k+1)
if(a==0):
	h=m//(k+1)
	print((y*k+z)*h)
else:
	r=m//(k+1)
	l=(k+1)*r
	o=(m-l)*z
	print((y*k+z)*r+o+m%(k+1))


n,m,k=map(int,input().split())
l=list(map(int,input().split()))
y=max(l)
l.remove(y)
z=max(l)
a=m%(k+1)
if(a==0):
	print((y*k+z)*a)
else:
	r=m//(k+1)
	l=(k+1)*r
	o=(m-l)*z
	print((y*k+z)*a+o)


n,m,k=map(int,input().split())
l=list(map(int,input().split()))
y=max(l)
l.remove(y)
z=max(l)
a=m//(k+1)
print((y*k+z)*a)


n,m,k=map(int,input().split())
l=list(map(int,input().split()))
y=max(l)
l.remove(y)
z=max(l)
a=m%(k+1)
if(a==0):
	h=m//(k+1)
	print((y*k+z)*h)
else:
	r=m//(k+1)
	l=(k+1)*r
	o=(m-l)*z
	print((y*k+z)*r+(m%(k+1))*y)


n,m,k=map(int,input().split())
l=list(map(int,input().split()))
y=max(l)
l.remove(y)
z=max(l)
a=m%(k+1)
if(a==0):
	h=m//(k+1)
	print((y*k+z)*h)
else:
	r=m//(k+1)
	l=(k+1)*r
	o=(m-l)*z
	print((y*k+z)*r+o+1+m%(k+1))


n, m, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = m//(k+1)
x = m%(k+1)
a1 = a*k*l[-1] + l[-2]*a + x*l[-1]
print(a1)


n, m, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = m//(k+1)
x = m%(k+1)
a1 = a*k*l[-1] + l[-2]*a + x*l[-1]*k + x*l[-2]
print(a1)


n, m, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = m//(k+1)
# print(a)
a1 = a*k*l[-1] + l[-2]*a
print(a1)


n, m, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = m//(k+1)
x = m%(k+1)
a1 = a*k*l[-1] + l[-2]*a + x*k*l[-1]
print(a1)


n, m, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = m//(k+1)
x = m%k
a1 = a*k*l[-1] + l[-2]*a + x*k*l[-1]
print(a1)


X = list(map(int, input().split()))
Emotes = sorted(list(map(int, input().split())), reverse=True)
print(Emotes[0] * X[1] if Emotes[0] == Emotes[1] else Emotes[0] * (X[1] - (X[1] // (X[2] + 1))) + Emotes[1] * (
            X[1] // (X[2] + 1)))


X = list(map(int, input().split()))
Emotes = sorted(list(map(int, input().split())), reverse=True)
print(Emotes[0] * (X[1] - (X[1] // (X[2] + 1))) + Emotes[1] * (X[1] // (X[2] + 1)))


import sys

def Ints(): return map(int, sys.stdin.readline().strip().split())
def Strs(): return map(str, sys.stdin.readline().strip().split())
def Array(): return list(map(int, sys.stdin.readline().strip().split()))
def Str(): return sys.stdin.readline().strip()
def Int(): return int(sys.stdin.readline().strip())
def MOD(): return 1000000007

def power(base, power):
    MOD = 1000000007
    result = 1
    while power > 0:
        if power % 2 == 1:
            result = (result * base) % MOD
        power = power // 2
        base = (base * base) % MOD
    return result

if __name__ == "__main__":
    n , m , k = Ints()

    a = Array()

    a = sorted(a,reverse=True)

    segments = m//(k+1) if (m%(k+1) == 0) else (m//(k))

    print((segments * k * a[0]) + segments * a[1] )


n,m,k = map(int,input().split())
arr = sorted(list([int(i) for i in input().split()]),reverse=True)[:2]
if k > 1:
    print(m*arr[0]- m)
else:
    print(m*arr[0])


import sys
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
# sys.setrecursionlimit(1000000)
def Ints(): return map(int, sys.stdin.readline().strip().split())
def Strs(): return map(str, sys.stdin.readline().strip().split())
def Array(): return list(map(int, sys.stdin.readline().strip().split()))
def Str(): return sys.stdin.readline().strip()
def Int(): return int(sys.stdin.readline().strip())
def MOD(): return 1000000007

def power(base, power):
    MOD = 1000000007
    result = 1
    while power > 0:
        if power % 2 == 1:
            result = (result * base) % MOD
        power = power // 2
        base = (base * base) % MOD
    return result

if __name__ == "__main__":
    n , m , k = Ints()

    a = Array()

    a = sorted(a,reverse=True)
    segments = m // (k+1)

    res = (segments * k * a[0]) + (segments * a[1])
    x = m%(k+1)

    if (x <= k):
        res += (x * a[0])
    print(res)


import sys
def Ints(): return map(int, sys.stdin.readline().strip().split())
def Strs(): return map(str, sys.stdin.readline().strip().split())
def Array(): return list(map(int, sys.stdin.readline().strip().split()))
def Str(): return sys.stdin.readline().strip()
def Int(): return int(sys.stdin.readline().strip())
def MOD(): return 1000000007

def power(base, power):
    MOD = 1000000007
    result = 1
    while power > 0:
        if power % 2 == 1:
            result = (result * base) % MOD
        power = power // 2
        base = (base * base) % MOD
    return result

if __name__ == "__main__":
    n , m , k = Ints()

    a = Array()

    a = sorted(a,reverse=True)

    segments = m//(k+1) if (m%(k+1) == 0) else (m//(k+1)) + 1

    print((segments * k * a[0]) + (segments * a[1]))


import sys
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
# sys.setrecursionlimit(1000000)
def Ints(): return map(int, sys.stdin.readline().strip().split())
def Strs(): return map(str, sys.stdin.readline().strip().split())
def Array(): return list(map(int, sys.stdin.readline().strip().split()))
def Str(): return sys.stdin.readline().strip()
def Int(): return int(sys.stdin.readline().strip())
def MOD(): return 1000000007

def power(base, power):
    MOD = 1000000007
    result = 1
    while power > 0:
        if power % 2 == 1:
            result = (result * base) % MOD
        power = power // 2
        base = (base * base) % MOD
    return result

if __name__ == "__main__":
    n , m , k = Ints()

    a = Array()

    a = sorted(a,reverse=True)

    segments = m//(k+1) if m%(k+1) == 0 else (m//(k+1)) + 1

    print((segments * k * a[0]) + segments * a[1] )


import sys
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
# sys.setrecursionlimit(1000000)
def Ints(): return map(int, sys.stdin.readline().strip().split())
def Strs(): return map(str, sys.stdin.readline().strip().split())
def Array(): return list(map(int, sys.stdin.readline().strip().split()))
def Str(): return sys.stdin.readline().strip()
def Int(): return int(sys.stdin.readline().strip())
def MOD(): return 1000000007

def power(base, power):
    MOD = 1000000007
    result = 1
    while power > 0:
        if power % 2 == 1:
            result = (result * base) % MOD
        power = power // 2
        base = (base * base) % MOD
    return result

if __name__ == "__main__":
    n , m , k = Ints()

    a = Array()

    a = sorted(a,reverse=True)

    segments = m//(k+1)

    print((segments * k * a[0]) + segments * a[1] )


n,m,k = map(int,input().split())
arr = sorted(list([int(i) for i in input().split()]),reverse=True)[:2]
if k > 1:
    print(m*(arr[0]-1))
else:
    print(m*arr[0])


n,m,k = map(int,input().split())
arr = sorted(list([int(i) for i in input().split()]),reverse=True)[:2]
if k > 1:
    print(m*arr[0]-1)
else:
    print(m*arr[0])


n,m,k = list(map(int, input().split()))
hap = list(map(int, input().split()))
max1,max2=0,0
for i in hap:
    if max1<=i:
        max2=max1
        max1=i
    elif max2<i<max1:
        max2=i
print((max1)*(m-m//(k+1))+(max2)*(m//(k+1)))


n,m,k = list(map(int, input().split()))
hap = list(map(int, input().split()))
max1 = max(hap)
hap.remove(max1)
max2 = max(hap)
print((max1)*(m-m//(k+1))+(max2)*(m//(k+1)))


n,m,k = map(int,input().split())
ln = list(map(int,input().split()))
mx = list(set(ln))[-1]
mn = list(set(ln))[-2]
t = 0
c = 2
while m > 0:
    if c != 0:
        t += mx
        c -= 1
    else:
        t += mn
        c = 2
    m -= 1
print(t)


n,m,k = map(int,input().split())
ln = list(map(int,input().split()))
mx = sorted(ln)[-1]
mn = sorted(ln)[-2]
print((mx*k+mn)*(m//(k+1))+(m%(k+1)*mx))


n,m,k = map(int,input().split())
ln = list(map(int,input().split()))
mx = sorted(ln)[-1]
mn = sorted(ln)[-2]
print((mx*k+mn)*(m//(k+1)))


n,m,k = map(int, input().split())
s = input().split()
z = []
for i in range(0,n):
    z.append(int(s[i]))
z = sorted(z)
print(round(m/(k+1))*(z[-1]*k+z[-2])+(m%(k+1))*z[-1])


n,m,k = map(int, input().split())
s = input().split()
z = []
for i in range(0,n):
    z.append(int(s[i]))
z = sorted(z)
print(m//(k+1)*(z[-1]*k+z[-2])+(m%(k+1))*z[-1])


nmk = input().strip().split(" ")
n = int(nmk[0])
m = int(nmk[1])
k = int(nmk[2])

emojis = input().strip().split(" ")
emojis = [int(x) for x in emojis]

max1 = max(emojis)
emojis.remove(max1)
max2 = max(emojis)

seq = max1 * k + max2
happ = m // (k + 1) * seq + m % (k + 1) * max1

print(happ)


nmk = input().strip().split(" ")
n = int(nmk[0])
m = int(nmk[1])
k = int(nmk[2])

emojis = input().strip().split(" ")
emojis = [int(x) for x in emojis]

max1 = max(emojis)
emojis.remove(max1)
max2 = max(emojis)

seq = max1 * k + max2
happ = m // (k + 1) * seq + m % (k + 1) * max2

print(happ)


t,m,k=map(int,input().split())
l=list(map(int,input().split()))
max1=max(l)
l.remove(max1)
max2=max(l)
ans = 0
a =m//(k+1)
ans = a*( k*max1 + max2)
b = m%(k+1)
ans += b*max1
print(ans)


t,m,k=map(int,input().split())
l=list(map(int,input().split()))
max1=max(l)
l.remove(max1)
max2=max(l)
ans = 0
while m >= k:
    ans += (k*max1)
    m   -= k
    if m > 0:
        ans += max2
    m -= 1
if m > 0:
    ans += (m*max1)
print(ans)


t,m,k=map(int,input().split())
l=list(map(int,input().split()))
max1=max(l)
l.remove(max1)
max2=max(l)
ans = 0
a =m//(k+1)
ans = a*( k*max1 + max2)
print(ans)
b = m%(k+1)
ans += b*max1
print(ans)


n,m,k = map(int,input().split(" "))

arr = list(map(int,input().split(" ")))

arr.sort()
s = 0
c = 0
for i in range(m):

	if(c<k):
		s += arr[-1]
		c += 1

	elif(c==k):
		s += arr[-2]
		c = 0

print(s)


n,m,k = map(int,input().split(" "))

arr = list(map(int,input().split(" ")))

arr.sort()
count = m//(k+1)

s = arr[-1]*count*k

s += arr[-2]*count

s += arr[-1]*(m%(k+1))

print(s)


n, m, k = map(int, input().strip().split())
arr = list( map(int, input().strip().split()) )

arr.sort(reverse = True)

joy = 0
q, r = divmod(m, k+1)
joy += arr[0] * q * k + arr[1] * q + arr[0] * r

print (joy)


n, m, k = map(int, input().strip().split())
arr = list( map(int, input().strip().split()) )

arr.sort(reverse = True)

joy = 0
q, r = divmod(m, k+1)
joy += arr[0] * q * k + arr[1] * (q + r)

print (joy)


n, m, k = map(int, input().split())
emotes = list(map(int, input().split()))
emotes.sort(reverse=True)

res = emotes[0] * (m // (k + 1)) * k + emotes[1] * (m // (k + 1)) + (m % (k + 1)) * emotes[0]
print(res)


n, m, k = map(int, input().split())
emotes = list(map(int, input().split()))
emotes.sort(reverse=True)

res = emotes[0] * (m // (k + 1)) * k + emotes[1] * (m // (k + 1)) + n % (k + 1) * emotes[0]
print(res)


n,m,k=map(int,input().split())
a=[int(s) for s in input().split()]
l=max(a)

for i in range(n):
    a[a.index(max(a))]=-1
    z=max(a)
    break

print((l*k+z)*m//(k+1)+(l*k+z)*m%(k+1))


n,m,k=map(int,input().split())
a=[int(s) for s in input().split()]
a.sort()
l,z=a[-1],a[-2]
print((l*k+z)*m//(k+1)+l*m%k))


n,m,k=map(int,input().split())
a=[int(s) for s in input().split()]
a.sort()
l,z=a[-1],a[-2]
print((l*k+z)*m//(k+1)+l*m%(k+1))


n,m,k=map(int,input().split())
a=[int(s) for s in input().split()]
a.sort()
l,z=a[-1],a[-2]

print((l*k+z)*m//(k+1)+l*(m%(k+1)))


n,m,k=map(int,input().split())
a=[int(s) for s in input().split()]
a.sort()
l,z=a[-1],a[-2]
print((l*k+z)*m//(k+1)+l*m%k)


n,m,k=map(int,input().split())
a=[int(s) for s in input().split()]
a.sort()
l,z=a[-1],a[-2]
print((l*k+z)*m//(k+1)+(l*k+z)*m%(k+1))


n,m,k=map(int,input().split())
a=[int(s) for s in input().split()]
a.sort()
l,z=a[-1],a[-2]

print((l*k+z)*m//(k+1)+l*m%(k+1))


n,m,k=map(int,input().split())
a=[int(s) for s in input().split()]
a.sort()
l,z=a[-1],a[-2]
x=m%(k+1)
print((l*k+z)*(m//(k+1))+l*(m%(k+1)))


str = input()
n = int(str.split(' ')[0])
m = int(str.split(' ')[1])
k = int(str.split(' ')[2])
a = []
r = 0
str = input()
for i in str.split(' '):
    a.append(int(i))
a.sort(reverse = True)
if m <= k:
    print(a[0]*k)
else:
    raz = int((m / (k+1)))
    r = int(a[0] * raz * k)
    r += int(a[1] * raz)
    r += int(a[0] * (m - (raz  * k + raz)))
    print(r)


str = input()
n = int(str.split(' ')[0])
m = int(str.split(' ')[1])
k = int(str.split(' ')[2])
a = []
r = 0
str = input()
for i in str.split(' '):
    a.append(int(i))
a.sort(reverse = True)
if m <= k:
    print(a[0]*k)
else:
    r = int(a[0] * (m / (k+1)) * k)
    r += int(a[1] * (m / (k+1)))
    print(r)


n,m,k=map(int,input().split())
a=list(map(int,input().split()))
arr=[]
a.sort()
arr.append(a[-1])
arr.append(a[-2])
x=arr[0]
y=arr[-1]
print((m//(k+1))*(x*k+y)+(m%(k+1))*x)


a=list(map(int,input().split()))
c=1000000007
if k==n:
    print((max(a)*m)%c)
else:
    arr=[]
    a.sort()
    arr.append(a[-1])
    arr.append(a[-2])
    s=0
    i=k
    c=0
    while i<m:
        s+=arr[-1]
        i+=3
        c+=1
    s+=arr[0]*(m-c)
    print(s)


h = 0

nmk_in = input()
nmk = list(map(int, nmk_in.split(' ')))

m = nmk[1]
k = nmk[2]

emotes_in = input()
emotes = list(map(int, emotes_in.split(' ')))

emotes.sort()
emotes.reverse()

i = 0
while m > 0:
    if (i%2==0):
        h += k*emotes[0]
        m -= k
    else:
        h += emotes[1]
        m -= 1
    i += 1

print(h)


h = 0

nmk_in = input()
nmk = list(map(int, nmk_in.split(' ')))

m = nmk[1]
k = nmk[2]

emotes_in = input()
emotes = list(map(int, emotes_in.split(' ')))

emotes.sort()
emotes.reverse()

n1 = m//(k+1)

h += n1*k*emotes[0]+(m-n1*k)*emotes[1]
h += (m-((k+1)*n1))*emotes[0]

print(h)


h = 0

nmk_in = input()
nmk = list(map(int, nmk_in.split(' ')))

m = nmk[1]
k = nmk[2]

emotes_in = input()
emotes = list(map(int, emotes_in.split(' ')))

emotes.sort()
emotes.reverse()

##i = 0
##while m > 0:
##    if (i%2==0):
##        h += k*emotes[0]
##        m -= k
##    else:
##        h += emotes[1]
##        m -= 1
##    i += 1

n1 = m//k
##print(n1)
h += (n1-1)*k*emotes[0]+(m-(n1-1)*k)*emotes[1]

print(h)


h = 0

nmk_in = input()
nmk = list(map(int, nmk_in.split(' ')))

m = nmk[1]
k = nmk[2]

emotes_in = input()
emotes = list(map(int, emotes_in.split(' ')))

emotes.sort()
emotes.reverse()

n1 = m//(k+1)
#print(n1)
#print(m-((k+1)*n1))

h += n1*k*emotes[0]+n1*emotes[1]
#print(h)
h += (m-((k+1)*n1))*emotes[0]
print(h)


h = 0

nmk_in = input()
nmk = list(map(int, nmk_in.split(' ')))

m = nmk[1]
k = nmk[2]

emotes_in = input()
emotes = list(map(int, emotes_in.split(' ')))

emotes.sort()
emotes.reverse()

##i = 0
##while m > 0:
##    if (i%2==0):
##        h += k*emotes[0]
##        m -= k
##    else:
##        h += emotes[1]
##        m -= 1
##    i += 1

n1 = m//(k+1)
##print(n1)
##h += (n1-1)*k*emotes[0]+(m-(n1-1)*k)*emotes[1]
h += n1*k*emotes[0]+(m-n1*k)*emotes[1]

print(h)


user_input = input().split(' ')

n = int(user_input[0])
m = int(user_input[1])
k = int(user_input[2])

row = input().split(' ')

list = []

for a in row:
  list.append(int(a))

list.sort() # 입력 받은 수를 정렬하기

first = list[n - 1] # 가장 큰 수
second = list[n - 2] # 두 번째로 큰 수

result = 0

# 가장 큰 수가 더해지는 횟수
count = int(m / (k + 1)) * k
count += m % (k + 1)

result += (count) * first # 가장 큰 수 더하기
result += (m - count) * second # 두 번째로 큰 수 더하기

print(result)


user_input = input().split(' ')

n = int(user_input[0])
m = int(user_input[1])
k = int(user_input[2])

row = input().split(' ')

list = []

for a in row:
  list.append(int(a))

list.sort() # 입력 받은 수를 정렬하기

first = list[n - 1] # 가장 큰 수
second = list[n - 2] # 두 번째로 큰 수

result = 0

# 가장 큰 수가 더해지는 횟수
count = int(m / (k + 1)) * k

result += count * first # 가장 큰 수 더하기
result += (m - count) * second # 두 번째로 큰 수 더하기

print(result)


user_input = input().split(' ')

n = int(user_input[0])
m = int(user_input[1])
k = int(user_input[2])

row = input().split(' ')

list = []

for a in row:
 list.append(int(a))

list.sort()

p = int(m / (k + 1))
a = int(p * k * list[n - 1])
b = int(p * list[n - 2])
c = int(m % (k + 1))
c *= list[n - 1]

print(a + b + c)


user_input = input().split(' ')

n = int(user_input[0])
m = int(user_input[1])
k = int(user_input[2])

row = input().split(' ')

list = []

for a in row:
  list.append(int(a))

list.sort()

first = list[n - 1]
second = list[n - 2]

result = 0

count = int(m / (k + 1)) * k
count += m % (k + 1)

result += (count) * first
result += (m - count) * second

print(result)


n,m,k = map(int, input().split())
ls = sorted(list(map(int, input().split())))
print((ls[-1]*k+ls[-2])*m//(k+1) + ls[-1]*(m%(k+1)))


n,m,k = map(int, input().split())
ls = sorted(list(map(int, input().split())))
print((ls[-1]*k+ls[-2])*(m//(k+1)) + ls[-1]*(m%(k+1)))


n,m,k=map(int,input().split())
numbers=list(map(int,input().split()))
y,x=sorted(numbers)[-2:]

val= ((m//(k+1))*((x*k)+y))
val2= (m%(k+1))*x

print(val+val2)


n,m,k=map(int,input().split())
numbers=list(map(int,input().split()))
x,y=0,0
x=max(numbers)
numbers.remove(max(numbers))
y=max(numbers)

val= (round(m/(k+1))*((x*k)+y))
val2= (m%(k+1))*x

print(val+val2)


n,m,k=map(int,input().split())
lis=list(map(int,input().split()))
x=max(lis)
lis[lis.index(x)]=-1
y=max(lis)
print(((k*x+y)*(m//(k+1)))+(m%(k+1))*x)


n,m,k=map(int,input().split())
lis=list(map(int,input().split()))
x=max(lis)
lis[lis.index(x)]=-1
y=max(lis)
c=0
f=0
if k==1:
	if m%2==0:
		print(x*m//2+y*m//2)
	else:
		print(x*(m+1)//2+y*(m//2))
else:
	while True:
		if f==0:
			if m<=k:
				c+=m*x
				m=0
				break
			c+=k*x
			m-=k
			f=1
		else:
			m-=1
			c+=y
			f=0
			if m==0:
				break
	print(c)


n,m,k=map(int,input().split())
lis=list(map(int,input().split()))
x=max(lis)
lis[lis.index(x)]=-1
y=max(lis)
print(((k*x+y)*(m//(k+1)))+m%(k+1))


def emotions(lst, m, k):
    return m // (k + 1) * (lst[-1] * k + lst[-2]) + (m % (k + 1)) * lst[-1]

n, M, K = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]
print(emotions(sorted(a), M, K))


def emotions(lst, m, k):
    return (m // (k + 1)) * (lst[0] * k + lst[1]) + (m % (k + 1)) * lst[0]

n, M, K = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]
print(emotions(sorted(a), M, K))


def emotions(lst, m, k):
    return (m // (k + 1)) * (lst[0] * k + lst[1]) + (m % k) * lst[0]

n, M, K = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]
print(emotions(sorted(a), M, K))


n, m, k = map(int, input().split())

a = list(map(int, input().split()))

a.sort(reverse = True)

ans = [a[0]] * k
ans.extend([a[1]])
ans = sum(ans)

ans *= m // (k + 1)
ans += (m % (k + 1)) * a[0]
print(ans)


n, m, k = map(int, input().split())

a = list(map(int, input().split()))

a.sort(reverse = True)

ans = a[0] * k + a[1]

ans *= m // (k + 1)
ans += (m % (k + 1)) * a[0]
print(ans)


n,m,k=input().split()
N=int(n)
M=int(m)
K=int(k)
vet=input().split()
valor=list()
maior=0
segmaior=0
cont=0
felicidade=0
for i in vet:
  valor.append(int(i))
  if int(i)>maior:
    maior=int(i)
  elif int(i)>segmaior:
    segmaior=int(i)
felicidade=segmaior*(int(M/(K+1)))+maior*(M-int(M/(K+1)))
print(felicidade)


n,m,k=input().split()
N=int(n)
M=int(m)
K=int(k)
vet=input().split()
valor=list()
maior=0
segmaior=0
cont=0
felicidade=0
for i in vet:
  valor.append(int(i))
valor.sort()
valor.reverse()
print(valor)
maior=valor[0]
segmaior=valor[1]
felicidade=((segmaior+K*maior)*(int(M/(K+1)))+maior*(M%(K+1)))
print(felicidade)


n,m,k=input().split()
N=int(n)
M=int(m)
K=int(k)
vet=input().split()
valor=list()
maior=0
segmaior=0
cont=0
felicidade=0
for i in vet:
  valor.append(int(i))
valor.sort()
maior=valor[0]
segmaior=valor[1]
felicidade=((segmaior+K*maior)*(int(M/(K+1)))+maior*(M%(K+1)))
print(felicidade)


n,m,k=input().split()
N=int(n)
M=int(m)
K=int(k)
vet=input().split()
valor=list()
maior=0
segmaior=0
cont=0
felicidade=0
for i in vet:
  valor.append(int(i))
  if int(i)>maior:
    maior=int(i)
  elif int(i)>segmaior:
    segmaior=int(i)
for i in range(M):
  if cont!=K:
    felicidade+=maior
    cont+=1
  else:
    cont=0
    felicidade+=segmaior
print(felicidade)


n,m,k=input().split()
N=int(n)
M=int(m)
K=int(k)
vet=input().split()
valor=list()
maior=0
segmaior=0
cont=0
felicidade=0
for i in vet:
  valor.append(int(i))
valor.sort()
valor.reverse()
maior=valor[0]
segmaior=valor[1]
felicidade=((segmaior+K*maior)*(int(M/(K+1)))+maior*(M%(K+1)))
print(felicidade)


n,m,k=input().split()
N=int(n)
M=int(m)
K=int(k)
vet=input().split()
valor=list()
maior=0
segmaior=0
cont=0
felicidade=0
for i in vet:
  valor.append(int(i))
  if int(i)>maior:
    maior=int(i)
  elif int(i)>segmaior:
    segmaior=int(i)

felicidade=((segmaior+K*maior)*(int(M/(K+1)))+maior*(M%(K+1)))
print(felicidade)


n, m, k = map(int, input().split())
a = list(map(int, input().split()))
max1 = max(a[0], a[1])
max2 = a[0] + a[1] - max1
for i in range(2, n):
    if a[i] >= max1:
        max2 = max1
        max1 = a[i]
    elif a[i] > max2:
        max2 = a[i]
print(max1 * (m - m // (k + 1)) + max2 * (m // (k + 1)))


n, m, k = map(int, input().split())
a = list(map(int, input().split()))
max1 = max(a[0], a[1])
max2 = a[0] + a[1] - max1
for el in a:
    if el >= max1:
        max2 = max1
        max1 = el
    elif el > max2:
        max2 = el
print(max1 * (m - m // (k + 1)) + max2 * (m // (k + 1)))


N,M,K=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
a=M//(K+1)
b=M%(K+1)
ans=(a*K+b)*l[0]+a*l[1]
print(ans)


N,M,K=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
print(l)
a=M//(K+1)
b=M%(K+1)
ans=(a*K+b)*l[0]+a*l[1]
print(ans)


n , m , k = map(int , input().split())
inp = [*map(int , input().split())]
inp.sort(reverse = True)
X = inp[0]
Y = inp[1]
i = 0
kk = m // (k + 1)
if m % 2 == 0:

     ans = kk * X * k + kk * Y
else:
     ans = kk * X * k + (kk - 1) * Y
print(ans)


n , m , k = map(int , input().split())
inp = [*map(int , input().split())]
inp.sort(reverse = True)
X = inp[0]
Y = inp[1]
i = 0
kk = m // (k + 1)
ans = kk * X * k + kk * Y
ans += m % (k + 1) * X
print(ans)


n , m , k = map(int , input().split())
inp = [*map(int , input().split())]
inp.sort(reverse = True)
X = inp[0]
Y = inp[1]
i = 0
kk = m // (k + 1)
ans = kk * X * k + kk * Y
print(ans)


from sys import stdin,stdout
from collections import Counter
def ai(): return list(map(int, stdin.readline().split()))
def ei(): return map(int, stdin.readline().split())
def ip(): return  int(stdin.readline().strip())
def op(ans): return stdout.write(str(ans) + '\n')

from math import ceil
n,m,k = ei()
emotes = ai();emotes.sort()
m1 = emotes[-1]
m2 = emotes[-2]
ans = x= 0
if m1 == m2 :
	print(m*m1)
elif k == 1:
	if m % 2 ==0 :
		print(m1*(m//2)+m2*(m//2))
	else:
		x = max(m1,m2)
		ans = ceil(m/2)*x
		print(ans + min(m1,m2)*(m//2))
else:
	x = ceil(m/(k+1))*(m1*k+m2)
	op(x)


from sys import stdin,stdout
from collections import Counter
def ai(): return list(map(int, stdin.readline().split()))
def ei(): return map(int, stdin.readline().split())
def ip(): return  int(stdin.readline().strip())
def op(ans): return stdout.write(str(ans) + '\n')

from math import ceil
n,m,k = ei()
emotes = ai();emotes.sort()
m1 = emotes[-1]
m2 = emotes[-2]
ans = x= 0
if m1 == m2 :
	print(m*m1)
elif k == 1:
	if m % 2 ==0 :
		print(m1*(m//2)+m2*(m//2))
	else:
		x = max(m1,m2)
		ans = ceil(m/2)*x
		print(ans + min(m1,m2)*(m//2))
else:
	while m>0 :
		if k <= m:
			ans += m1*k
			m -= k
			if m > 0:
				m -= 1
				ans += m2
	print(ans)


from sys import stdin,stdout
from collections import Counter
def ai(): return list(map(int, stdin.readline().split()))
def ei(): return map(int, stdin.readline().split())
def ip(): return  int(stdin.readline().strip())
def op(ans): return stdout.write(str(ans) + '\n')

from math import ceil
n,m,k = ei()
emotes = ai();emotes.sort()
m1 = emotes[-1]
m2 = emotes[-2]
ans = x= 0
if m1 == m2 :
	print(m*m1)
elif k == 1:
	if m % 2 ==0 :
		print(m1*(m//2)+m2*(m//2))
	else:
		x = max(m1,m2)
		ans = ceil(m/2)*x
		print(ans + min(m1,m2)*(m//2))
else:
	x = ceil(m/(k+1))*(m1*k+m2)+(m%(k+1))*m1
	op(x)


from sys import stdin,stdout
from collections import Counter
def ai(): return list(map(int, stdin.readline().split()))
def ei(): return map(int, stdin.readline().split())
def ip(): return  int(stdin.readline().strip())
def op(ans): return stdout.write(str(ans) + '\n')

n,m,k = ei()
emotes = ai();emotes.sort()
m1 = emotes[-1]
m2 = emotes[-2]
x = ((m//(k+1))*(m1*k+m2))+((m%(k+1))*m1)
op(x)


from sys import stdin,stdout
from collections import Counter
def ai(): return list(map(int, stdin.readline().split()))
def ei(): return map(int, stdin.readline().split())
def ip(): return  int(stdin.readline().strip())
def op(ans): return stdout.write(str(ans) + '\n')

from math import ceil
n,m,k = ei()
emotes = ai();emotes.sort()
m1 = emotes[-1]
m2 = emotes[-2]
x = (ceil(m/(k+1))*(m1*k+m2))+((m%(k+1))*m1)
op(x)


m,n,k=map(int, input().split())
emotes=list(map(int, input().split()))
rs=0
emotes.sort()
emotes.reverse()
lan=k+1
mot=emotes[0]*k+emotes[1]
rs=int(n/lan)*mot
rs+=n%lan*emotes[0]
print(rs)


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    cin >> n >> k >> x;
    long long mul = round(pow(x, k));
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];

    for (int i = 1; i <= n; ++i) {
        cin >> numbers[i];
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <= n; ++i) {
        result = max(result, prefix[i - 1] | numbers[i] * mul | suffix[i + 1]);
    }

    cout << result << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    scanf("%d%d%d", &n, &k, &x);
    long long mul = round(pow(x, k));
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%li",  &numbers[i]);
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <= n; ++i) {
        result = max(result, prefix[i - 1] | numbers[i] * mul | suffix[i + 1]);
    }
    printf("%lli\n", result);

    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    cin >> n >> k >> x;
    long long mul = 1;
    while (k--) {
        mul *= x;
    }
    long long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> numbers[i];
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <= n; ++i) {
        numbers[i] = prefix[i - 1] | numbers[i] * mul | suffix[i + 1];
        if (numbers[i] > result) {
            result = numbers[i];
        }
    }
    cout << result << endl;

    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
const int SIZE = 2e5+2;
long long a[SIZE],prefix[SIZE],suffix[SIZE];
int main(){
    int n,k,x;
    scanf("%d%d%d", &n, &k, &x);
    long long mul=1;
    while(k--)
        mul *= x;
    for(int i = 1; i <= n; i++)
        scanf("%I64d", &a[i]);
    for(int i = 1; i <= n; i++)
        prefix[i] = prefix[i-1] | a[i];
    for(int i = n; i > 0; i--)
        suffix[i] = suffix[i+1] | a[i];
    long long ans = 0;
    for(int i= 1; i <= n; i++)
        ans = max(ans, prefix[i-1] | (a[i] * mul) | suffix[i+1]);
    printf("%I64d\n",ans);
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    cin >> n >> k >> x;
    long long mul = round(pow(x, k));
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> numbers[i];
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <= n; ++i) {
        result = max(result, prefix[i - 1] | numbers[i] * mul | suffix[i + 1]);
    }

    cout << result << endl;

    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    cin >> n >> k >> x;
    long long mul = pow(x, k);
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n+1] = 0;
    for (int i = 1; i <=n; ++i) {
        cin >> numbers[i];
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i>0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <=n; ++i) {
        result = max(result, prefix[i - 1] | numbers[i] * mul | suffix[i + 1]);
    }

    cout << result << endl;

    return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    scanf("%d%d%d", &n, &k, &x);
    long long mul = 1;
    while (k--) {
        mul *= x;
    }
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%li",  &numbers[i]);
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <= n; ++i) {
        result = max(result, prefix[i - 1] | numbers[i] * mul | suffix[i + 1]);
    }
    printf("%lli\n", result);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    scanf("%d%d%d", &n, &k, &x);
    long long mul = 1;
    while (k--) {
        mul *= x;
    }
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%li",  &numbers[i]);
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <= n; ++i) {
        result = max(result, prefix[i - 1] | numbers[i] * mul | suffix[i + 1]);
    }
    printf("%lli\n", result);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
inline int in(int d=0,char q=0,int c=1){while(q!='-'&&q!=EOF&&(q<48||q>57))q=getchar();if(q==EOF)return EOF;if(q=='-')c=-1,q=getchar();do d=d*10+(q^48),q=getchar();while(q<58&&q>47);return c*d;}
int main() {
    int n= in(), k = in(), x= in();
    long long result = 0;
    long mul = 1;
    while (k--) {
        mul *= x;
    }
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        numbers[i] = in();
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    long long temp;
    for (int i = 1; i <= n; ++i) {
        temp = prefix[i - 1] | numbers[i] * mul | suffix[i + 1] ;

        if (temp > result) {
            result = temp;
        }
    }
    cout << result << endl;

    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    cin >> n >> k >> x;
    long long mul = pow(x, k);
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    for (int i = 1; i <=n; ++i) {
        cin >> numbers[i];
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i>0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <=n; ++i) {
        result = max(result, prefix[i - 1] | numbers[i] * mul | suffix[i + 1]);
    }

    cout << result << endl;

    return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    scanf("%d%d%d", &n, &k, &x);
    long long mul = 1;
    while (k--) {
        mul *= x;
    }
    long long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%lli",  &numbers[i]);
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <= n; ++i) {
        result = max(result, prefix[i - 1] | numbers[i] * mul | suffix[i + 1]);
    }
    printf("%lli\n", result);

    return 0;
}


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

int main() {
    int n, k, x;
    long long result = 0;
    cin >> n >> k >> x;
    long long mul = 1;
    while (k--) {
        mul *= x;
    }
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> numbers[i];
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    for (int i = 1; i <= n; ++i) {
        result = max(result, prefix[i - 1] | numbers[i] * mul | suffix[i + 1]);
    }

    cout << result << endl;

    return 0;
}


#include <cstdio>

using namespace std;

int main() {
    int n, k, x;
    long long result = 0;
    scanf("%d%d%d", &n, &k, &x);
    long long mul = 1;
    while (k--) {
        mul *= x;
    }
    long numbers[n + 2], prefix[n + 2], suffix[n + 2];
    prefix[0] = 0;
    suffix[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%li",  &numbers[i]);
        prefix[i] = prefix[i - 1] | numbers[i];
    }
    for (int i = n; i > 0; --i) {
        suffix[i] = suffix[i + 1] | numbers[i];
    }
    long long temp;
    for (int i = 1; i <= n; ++i) {
        temp = prefix[i - 1] | numbers[i] * mul | suffix[i + 1] ;

        if (temp > result) {
            result = temp;
        }
    }
    printf("%lli\n", result);

    return 0;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long n , k , x , foo;
    cin >> n >> k >> x;
    vector<long> list;
    for (int i = 0 ; i < n ; i ++)
    {
        cin >> foo;
        list.push_back(foo);
    }
    sort(list.begin(),list.end());
    long long last = list[n-1];
    for (int i = 1 ; i <= k ; i ++)
        last = (long long) last * x;
    for (int i = 0 ; i < n-1 ; i ++)
        last = (long long) last | list[i];
    cout << last << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int main()
{
    int n , k , x;
    long long Sum = 0;
    scanf("%d %d %d",&n,&k,&x);
    long long list[n];
    for (int i = 0 ; i < n ; i ++)
        cin >> list[i];
    sort(list,list+n);
    for (int j = 1 ; j <= k ; j ++)
    {
        list[n-1] *= x;
    }
    for (int j = 0 ; j < n ; j ++)
        Sum = Sum | list[j];
    cout << Sum << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int suffix[1000000] , prefix[1000000];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long ans = 0;
    int n , k , x , foo;
    cin >> n >> k >> x;
    vector<int> list {0};
    long long c = pow(x,k);
    for(int i = 0 ; i < n ; i ++)
    {
        scanf("%d",&foo);
        list.push_back(foo);
    }
    for (int i = 1 ; i <= n ; i ++)
        prefix[i] = prefix[i-1] | list[i];
    for (int i = n ; i > 0 ; i --)
        suffix[i] = suffix[i+1] | list[i];
    for (int i = 1 ; i <= n ; i ++)
    {
        ans = max(ans,prefix[i-1] | (list[i] * c) | (suffix[i+1]));
    }
    cout << ans << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int main()
{
    int n , k , x;
    long long Sum = 0;
    cin >> n >> k >> x;
    int list[n];
    for (int i = 0 ; i < n ; i ++)
    {
    //    cin >> list[i];
        list[i] = 1e9;
    }
    sort(list,list+n);
    long long last = list[n-1];
    for (int i = 1 ; i <= k ; i ++)
    {
        last *= x;
    }
//    last = (long long)last * pow(x,k);
    for (int j = 0 ; j < n-1 ; j ++)
        Sum = Sum | list[j];
    cout << (long long)(Sum|last) << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
long long suffix[1000000] , prefix[1000000] , theList[250000];
int main()
{
    int n , k , x;
    cin >> n >> k >> x;
    long long c = 1 ,  ans = 0;
    for (int i = 1 ; i <= k ; i ++)
        c *= x;
    for (int i = 1 ; i <= n ; i ++)
        cin >> theList[i];
    for (int i = 1 ; i <= n ; i ++)
        prefix[i] = prefix[i-1] | theList[i];
    for (int i = n ; i > 0 ; i --)
        suffix[i] = suffix[i+1] | theList[i];
    for (int i = 1 ; i <= n ; i ++)
        ans = max(ans,prefix[i-1] | (theList[i] * c) | suffix[i+1]);
    cout << ans << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int suffix[1000000] , prefix[1000000];
int main()
{
    memset(suffix,0,sizeof(suffix));
    memset(prefix,0,sizeof(prefix));
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long ans = 0;
    int n , k , x , foo;
    cin >> n >> k >> x;
    vector<int> list {0};
    long long c = pow(x,k);
    for(int i = 0 ; i < n ; i ++)
    {
        scanf("%d",&foo);
        list.push_back(foo);
    }
    for (int i = 1 ; i <= n ; i ++)
        prefix[i] = prefix[i-1] | list[i];
    for (int i = n ; i > 0 ; i --)
        suffix[i] = suffix[i+1] | list[i];
    for (int i = 1 ; i <= n ; i ++)
    {
        ans = max(ans,prefix[i-1] | (list[i] * c) | (suffix[i+1]));
    }
    cout << ans << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long n , k , x , foo;
    cin >> n >> k >> x;
    vector<long> list;
    for (int i = 0 ; i < n ; i ++)
    {
        cin >> foo;
        list.push_back(foo);
    }
    sort(list.begin(),list.end());
    long long last = list[n-1];
    for (int i = 1 ; i <= k ; i ++)
        last = (long long) last * x;
    for (int i = 0 ; i < n-1 ; i ++)
        last |= list[i];
    cout << last << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int suffix[1000000] , prefix[1000000] , theList[250000];
int main()
{
    int n , k , x;
    cin >> n >> k >> x;
    long long c = pow(x,k) , ans = 0;
    for (int i = 0 ; i < n ; i ++)
    {
        cin >> theList[i+1];
    }
    for (int i = 1 ; i <= n ; i ++)
        prefix[i] = prefix[i-1] | theList[i];
    for (int i = n ; i > 0 ; i --)
        suffix[i] = suffix[i+1] | theList[i];
    for (int i = 1 ; i <= n ; i ++)
    {
        ans = max(ans,prefix[i-1] | (theList[i] * c) | suffix[i+1]);
    }
    cout << ans << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
long long suffix[1000000] , prefix[1000000] , theList[250000];
int main()
{
    int n , k , x;
    cin >> n >> k >> x;
    long long mx = 0 ;
    long long c = 1 ,  ans = 0;
    for (int i = 1 ; i <= k ; i ++)
        c *= x;
    for (int i = 1 ; i <= n ; i ++)
    {
        cin >> theList[i];
        mx = max(mx,theList[i]);
    }
    for (int i = 1 ; i <= n ; i ++)
        prefix[i] = prefix[i-1] | theList[i];
    for (int i = n ; i > 0 ; i --)
        suffix[i] = suffix[i+1] | theList[i];
    for (int i = 1 ; i <= n ; i ++)
    {
        if (theList[i] * c > mx)
            ans = max(ans,prefix[i-1] | (theList[i] * c) | suffix[i+1]);
    }
    cout << ans << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int main()
{
    int n , k , x;
    long long Sum = 0;
    cin >> n >> k >> x;
    int list[n];
    for (int i = 0 ; i < n ; i ++)
    {
        cin >> list[i];
    }
    sort(list,list+n);
    long long last = list[n-1];
    for (int j = 1 ; j <= k ; j ++)
    {
        last *= x;
    }
    for (int j = 0 ; j < n-1 ; j ++)
        Sum = Sum | list[j];
    Sum = Sum|last;
    cout << Sum << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int main()
{
    int n , k , x;
    long long Sum = 0;
    cin >> n >> k >> x;
    int list[n];
    for (int i = 0 ; i < n ; i ++)
    {
        cin >> list[i];
    }
    sort(list,list+n);
    long long last = list[n-1];
    for (int i = 1 ; i <= k ; i ++)
    {
        last *= x;
    }
    long long g = 1;
    while (g <= last)
    {
        if ((g & last) == g)
        {
            Sum += g;
        }
        else
        {
            for (int i = 0 ; i < n-1 ; i ++)
            {
                if ((g & list[i]) == g)
                {
                    Sum += g;
                    break;
                }
            }
        }

        g *= 2;
    }
    cout << Sum << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int main()
{
    int n , k , x;
    long long Sum = 0;
    cin >> n >> k >> x;
    int list[n];
    for (int i = 0 ; i < n ; i ++)
    {
        cin >> list[i];
    //    list[i] = 1e9;
    }
    sort(list,list+n);
    long long last = list[n-1];
    for (int i = 1 ; i <= k ; i ++)
    {
        last *= x;
    }
//    last = (long long)last * pow(x,k);
    for (int j = 0 ; j < n-1 ; j ++)
        Sum = Sum | list[j];
    cout << (long long)(Sum|last) << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
int main()
{
    int n , k , x;
    long long Sum = 0;
    scanf("%d %d %d",&n,&k,&x);
    long long list[n];
    for (int i = 0 ; i < n ; i ++)
        cin >> list[i];
    sort(list,list+n);
    for (int j = 1 ; j <= k ; j ++)
    {
        list[n-1] *= x;
    }
    long long g = 1;

    while (g <= list[n-1])
    {
        for (int i = 1 ; i <= n ; i ++)
        {
            if (list[i-1] & g)
            {
                Sum += g;
                break;
            }
        }
        g *= 2;
    }
    cout << Sum << endl;
}


//
//  main.cpp
//  WorkingProject
//
//  Created by soroosh zare on 8/24/15.
//  Copyright (c) 2015 soroosh zare. All rights reserved.
//

/*
 ──────────────────────────────────────
 ─▄▄▄───────────▄▄▄▄▄▄▄────────────────
 █▀░▀█──────▄▀▀▀░░░░░░░▀▀▄▄────────────
 █░░░░█───▄▀░░░░░░░░░░░░░░░▀▄───────▄▄▄
 █▄░░░▀▄▄▀░░██░░░░░░░░░░░░░░▀█────█▀▀░█
 ─█░░░░█▀░░░▀░░░░░░░░██░░░░░░▀█─▄█░░░░█
 ─▀█░░▄█░░░░░░░▄▄▄░░░░▀░░░░░░░███░░░░█▀
 ──█▄░█░░░░░▄███████▄░░░░░░░░░█▀░░░░▄▀─
 ──▀█░█░░░░▄██████████░░░░░░░▄█░░░░▄▀──
 ───███░░░░███████████░░░░░░▄█░░░░█▀───
 ────█░░░░░██████████▀░░░░░░█░░░░█▀────
 ────█░░░░░░▀███████▀░░░░░░░█▄▄▄▀──────
 ────█░░░░░░░░▀▀▀▀░░░░░░░░░░░▀█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ────█░░░░░░░░░░░░░░░░░░░░░░░░█────────
 ──────────────────────────────────────
 */

#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include <numeric>
#include <utility>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <bitset>
#include <set>
#include <unordered_set>
#include <sstream>
#include <math.h>
#include <fstream>

#include <deque>
//#define cin fin
#define endl "\n"
#define P_String "3.1415926535897932384626433832795"
#define P_Number 3.1415926535897932384626433832795
#define INF 1e15
#define MAX_N 1e6 + 5
#define MOD 1e9+7
using namespace std;
inline string get_string() {char ch[1000000]; scanf("%s",ch); return ch; }
long long suffix[1000000] , prefix[1000000] , theList[250000];
int main()
{
    long long n , k , x;
    cin >> n >> k >> x;
    long long c = pow(x,k) , ans = 0;
    for (int i = 0 ; i < n ; i ++)
    {
        cin >> theList[i+1];
    }
    for (int i = 1 ; i <= n ; i ++)
        prefix[i] = prefix[i-1] | theList[i];
    for (int i = n ; i > 0 ; i --)
        suffix[i] = suffix[i+1] | theList[i];
    for (int i = 1 ; i <= n ; i ++)
    {
        ans = max(ans,prefix[i-1] | (theList[i] * c) | suffix[i+1]);
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    unsigned long long n, k, x;
    cin >> n >> k >> x;
    unsigned long long *A = new unsigned long long[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    x = power(x,k);
    unsigned long long temp = (static_cast<unsigned long long>(1) << static_cast<long long>(log2(A[n-1])));
    int temp_i=0;
    for(temp_i=0;temp_i<n;++temp_i)
        if(A[temp_i] > temp)
            break;
    unsigned long long *pre = new unsigned long long[n+1];
    pre[0] = A[0];
    for(int i=1;i<n;++i)
        pre[i] = pre[i-1] | A[i];
    unsigned long long *suf = new unsigned long long[n+1];
    suf[n] = 0;
    suf[n-1] = A[n-1];
    for(int i=n-2;i>=0;--i)
        suf[i] = suf[i+1] | A[i];
    unsigned long long max0 = 0;
    if(temp_i == 0)
    {
        max0 = (A[0]*x) | suf[1];
        temp_i++;
    }
    for(int i=temp_i;i<n-1;++i)
    {
        temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
        max0 = max(max0,temp);
    }
    if(n != 1)
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
    cout << max0 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    int n, k, x;
    cin >> n >> k >> x;
    unsigned int *A = new unsigned int[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    if(k == 1)
    {
        vector <unsigned int> v;
        for(int i=0;i<n;++i)
            v.push_back(A[i]);
        vector<unsigned int>::iterator it;
        it = unique(v.begin(),v.end());
        v.resize(distance(v.begin(),it));
        unsigned int temp = (static_cast<unsigned int>(1) << static_cast<int>(log2(v[v.size()-1])));
        int temp_i=0;
        for(temp_i=0;temp_i<v.size();++temp_i)
            if(v[temp_i] >= temp)
                break;
        unsigned int *pre = new unsigned int[n+1];
        pre[0] = A[0];
        for(int i=1;i<n;++i)
            pre[i] = pre[i-1] | A[i];
        unsigned int *suf = new unsigned int[n+1];
        suf[n-1] = A[n-1];
        for(int i=n-2;i>=0;--i)
            suf[i] = suf[i+1] | A[i];
        unsigned int max0 = 0;
        if(temp_i == 0)
        {
            max0 = A[0]*x;
            temp_i++;
        }
        for(int i=temp_i;i<n-1;++i)
        {
            temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
            max0 = max(max0,temp);
        }
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
        cout << max0 << endl;
    }
    else
    {
        unsigned long long ans = A[n-1] * power(x,k);
        for(int i=n-2;i>=0;--i)
            ans |= A[i];
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    int n, k, x;
    cin >> n >> k >> x;
    unsigned int *A = new unsigned int[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    if(k == 1)
    {
        vector <unsigned int> v;
        for(int i=0;i<n;++i)
            v.push_back(A[i]);
        vector<unsigned int>::iterator it;
        it = unique(v.begin(),v.end());
        v.resize(distance(v.begin(),it));
        unsigned int temp = (static_cast<unsigned int>(1) << static_cast<int>(log2(v[v.size()-1])));
        int temp_i=0;
        for(temp_i=0;temp_i<v.size();++temp_i)
            if(v[temp_i] >= temp)
                break;
        unsigned int *pre = new unsigned int[n+1];
        pre[0] = A[0];
        for(int i=1;i<n;++i)
            pre[i] = pre[i-1] | A[i];
        unsigned int *suf = new unsigned int[n+1];
        suf[n-1] = A[n-1];
        for(int i=n-2;i>=0;--i)
            suf[i] = suf[i+1] | A[i];
        unsigned int max0 = 0;
        if(temp_i == 0)
        {
            max0 = A[0]*x | suf[1];
            temp_i++;
        }
        for(int i=temp_i;i<n-1;++i)
        {
            temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
            max0 = max(max0,temp);
        }
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
        cout << max0 << endl;
    }
    else
    {
        unsigned long long ans = A[n-1] * power(x,k);
        for(int i=n-2;i>=0;--i)
            ans |= A[i];
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    int n, k, x;
    cin >> n >> k >> x;
    unsigned long long *A = new unsigned long long[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    A[n-1] *= power(x,k);
    unsigned long long ans = 0;
    for(int i=0;i<n;++i)
        ans |= A[i];
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    int n, k, x;
    cin >> n >> k >> x;
    unsigned int *A = new unsigned int[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    if(k == 1)
    {
        vector <unsigned int> v;
        for(int i=0;i<n;++i)
            v.push_back(A[i]);
        vector<unsigned int>::iterator it;
        it = unique(v.begin(),v.end());
        v.resize(distance(v.begin(),it));
        unsigned int temp = (static_cast<unsigned int>(1) << static_cast<int>(log2(v[v.size()-1])));
        int temp_i=0;
        for(temp_i=0;temp_i<v.size();++temp_i)
            if(v[temp_i] >= temp)
                break;
        unsigned int *pre = new unsigned int[n+1];
        pre[0] = A[0];
        for(int i=1;i<n;++i)
            pre[i] = pre[i-1] | A[i];
        unsigned int *suf = new unsigned int[n+1];
        suf[n-1] = A[n-1];
        for(int i=n-2;i>=0;--i)
            suf[i] = suf[i+1] | A[i];
        unsigned int max0 = 0;
        if(temp_i == 0)
        {
            max0 = A[0]*x | suf[1];
            temp_i++;
        }
        for(int i=temp_i;i<n-1;++i)
        {
            temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
            max0 = max(max0,temp);
        }
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
        cout << max0 << endl;
    }
    else
    {
        unsigned long long ans = static_cast<unsigned long long>(A[n-1]) * power(x,k);
        for(int i=n-2;i>=0;--i)
            ans |= static_cast<unsigned long long>(A[i]);
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    unsigned long long n, k, x;
    cin >> n >> k >> x;
    unsigned long long *A = new unsigned long long[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    x = power(x,k);
    unsigned long long *pre = new unsigned long long[n+1];
    pre[0] = A[0];
    for(int i=1;i<n;++i)
        pre[i] = pre[i-1] | A[i];
    unsigned long long *suf = new unsigned long long[n+1];
    suf[n] = 0;
    suf[n-1] = A[n-1];
    for(int i=n-2;i>=0;--i)
        suf[i] = suf[i+1] | A[i];
    unsigned long long max0 = 0, temp;
    max0 = (A[0]*x) | suf[1];
    for(int i=1;i<n-1;++i)
    {
        temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
        max0 = max(max0,temp);
    }
    if(n != 1)
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
    cout << max0 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    unsigned long long n, k, x;
    cin >> n >> k >> x;
    unsigned long long *A = new unsigned long long[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    x = power(x,k);
    unsigned long long temp = (static_cast<unsigned long long>(1) << static_cast<long long>(log2(A[n-1])));
    int temp_i=0;
    for(temp_i=0;temp_i<n;++temp_i)
        if(A[temp_i] >= temp)
            break;
    unsigned long long *pre = new unsigned long long[n+1];
    pre[0] = A[0];
    for(int i=1;i<n;++i)
        pre[i] = pre[i-1] | A[i];
    unsigned long long *suf = new unsigned long long[n+1];
    suf[n] = 0;
    suf[n-1] = A[n-1];
    for(int i=n-2;i>=0;--i)
        suf[i] = suf[i+1] | A[i];
    unsigned long long max0 = 0;
    if(temp_i == 0)
    {
        max0 = A[0]*x | suf[1];
        temp_i++;
    }
    for(int i=temp_i;i<n-1;++i)
    {
        temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
        max0 = max(max0,temp);
    }
    max0 = max(max0, pre[n-2] | (A[n-1]*x));
    cout << max0 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    int n, k, x;
    cin >> n >> k >> x;
    unsigned int *A = new unsigned int[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    if(k == 1)
    {
        vector <unsigned int> v;
        for(int i=0;i<n;++i)
            v.push_back(A[i]);
        vector<unsigned int>::iterator it;
        it = unique(v.begin(),v.end());
        v.resize(distance(v.begin(),it));
        unsigned int temp = (1 << static_cast<int>(log2(v[v.size()-1])));
        int temp_i=0;
        for(temp_i=0;temp_i<v.size();++temp_i)
            if(v[temp_i] >= temp)
                break;
        unsigned int *pre = new unsigned int[n+1];
        pre[0] = A[0];
        for(int i=1;i<n;++i)
            pre[i] = pre[i] | A[i];
        unsigned int *suf = new unsigned int[n+1];
        suf[n-1] = A[n-1];
        for(int i=n-2;i>=0;--i)
            suf[i] = suf[i] | A[i];
        unsigned int max0 = 0;
        if(temp_i == 0)
        {
            max0 = A[0]*x;
            temp_i++;
        }
        for(int i=temp_i;i<n-1;++i)
        {
            temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
            max0 = max(max0,temp);
        }
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
        cout << max0 << endl;
    }
    else
    {
        unsigned long long ans = A[n-1] * power(x,k);
        for(int i=n-2;i>=0;--i)
            ans |= A[i];
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    unsigned long long n, k, x;
    cin >> n >> k >> x;
    unsigned long long *A = new unsigned long long[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    x = power(x,k);
    unsigned long long *pre = new unsigned long long[n+1];
    pre[0] = A[0];
    for(int i=1;i<n;++i)
        pre[i] = pre[i-1] | A[i];
    unsigned long long *suf = new unsigned long long[n+1];
    suf[n] = 0;
    suf[n-1] = A[n-1];
    for(int i=n-2;i>=0;--i)
        suf[i] = suf[i+1] | A[i];
    unsigned long long max0 = 0, temp;
    max0 = (A[0]*x) | suf[1];
    for(int i=1;i<n-1;++i)
    {
        temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
        max0 = max(max0,temp);
    }
    if(n != 1)
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
    cout << max0 << endl;
    free(A);
    free(pre);
    free(suf);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    unsigned long long n, k, x;
    cin >> n >> k >> x;
    unsigned long long *A = new unsigned long long[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    x = power(x,k);
    unsigned long long temp = (static_cast<unsigned long long>(1) << static_cast<long long>(log2(A[n-1])));
    int temp_i=0;
    unsigned long long *pre = new unsigned long long[n+1];
    pre[0] = A[0];
    for(int i=1;i<n;++i)
        pre[i] = pre[i-1] | A[i];
    unsigned long long *suf = new unsigned long long[n+1];
    suf[n] = 0;
    suf[n-1] = A[n-1];
    for(int i=n-2;i>=0;--i)
        suf[i] = suf[i+1] | A[i];
    unsigned long long max0 = 0;
    if(temp_i == 0)
    {
        max0 = (A[0]*x) | suf[1];
        temp_i++;
    }
    for(int i=temp_i;i<n-1;++i)
    {
        temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
        max0 = max(max0,temp);
    }
    if(n != 1)
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
    cout << max0 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    unsigned long long n, k, x;
    cin >> n >> k >> x;
    unsigned long long *A = new unsigned long long[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    x = power(x,k);
    vector <unsigned long long> v;
    for(int i=0;i<n;++i)
        v.push_back(A[i]);
    vector<unsigned long long>::iterator it;
    it = unique(v.begin(),v.end());
    v.resize(distance(v.begin(),it));
    unsigned long long temp = (static_cast<unsigned long long>(1) << static_cast<long long>(log2(v[v.size()-1])));
    int temp_i=0;
    for(temp_i=0;temp_i<v.size();++temp_i)
        if(v[temp_i] >= temp)
            break;
    unsigned long long *pre = new unsigned long long[n+1];
    pre[0] = A[0];
    for(int i=1;i<n;++i)
        pre[i] = pre[i-1] | A[i];
    unsigned long long *suf = new unsigned long long[n+1];
    suf[n-1] = A[n-1];
    for(int i=n-2;i>=0;--i)
        suf[i] = suf[i+1] | A[i];
    unsigned long long max0 = 0;
    if(temp_i == 0)
    {
        max0 = A[0]*x | suf[1];
        temp_i++;
    }
    for(int i=temp_i;i<n-1;++i)
    {
        temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
        max0 = max(max0,temp);
    }
    max0 = max(max0, pre[n-2] | (A[n-1]*x));
    cout << max0 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    unsigned long long n, k, x;
    cin >> n >> k >> x;
    unsigned long long *A = new unsigned long long[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    x = power(x,k);
    unsigned long long temp = (static_cast<unsigned long long>(1) << static_cast<long long>(log2(A[n-1])));
    int temp_i=0;
    for(temp_i=0;temp_i<n;++temp_i)
        if(A[temp_i] >= temp)
            break;
    unsigned long long *pre = new unsigned long long[n+1];
    pre[0] = A[0];
    for(int i=1;i<n;++i)
        pre[i] = pre[i-1] | A[i];
    unsigned long long *suf = new unsigned long long[n+1];
    suf[n] = 0;
    suf[n-1] = A[n-1];
    for(int i=n-2;i>=0;--i)
        suf[i] = suf[i+1] | A[i];
    unsigned long long max0 = 0;
    if(temp_i == 0)
    {
        max0 = (A[0]*x) | suf[1];
        temp_i++;
    }
    for(int i=temp_i;i<n-1;++i)
    {
        temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
        max0 = max(max0,temp);
    }
    if(n != 1)
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
    cout << max0 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

inline unsigned long long power(unsigned long long base,int exp)
{
    unsigned long long ans=1;
    while(exp)
    {
        if(exp%2==1)
            ans=(ans*base);
        base=(base*base);
        exp/=2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    int n, k, x;
    cin >> n >> k >> x;
    unsigned int *A = new unsigned int[n+1];
    for(int i=0;i<n;++i)
        cin >> A[i];
    sort(A,A+n);
    if(k == 1)
    {
        vector <unsigned int> v;
        for(int i=0;i<n;++i)
            v.push_back(A[i]);
        vector<unsigned int>::iterator it;
        it = unique(v.begin(),v.end());
        v.resize(distance(v.begin(),it));
        unsigned int temp = (1 << static_cast<int>(log2(v[v.size()-1])));
        int temp_i=0;
        for(temp_i=0;temp_i<v.size();++temp_i)
            if(v[temp_i] >= temp)
                break;
        unsigned int *pre = new unsigned int[n+1];
        pre[0] = A[0];
        for(int i=1;i<n;++i)
            pre[i] = pre[i] | A[i];
        unsigned int *suf = new unsigned int[n+1];
        suf[n-1] = A[n-1];
        for(int i=n-2;i>=0;--i)
            pre[i] = pre[i] | A[i];
        unsigned int max0 = 0;
        if(temp_i == 0)
        {
            max0 = A[0]*x;
            temp_i++;
        }
        for(int i=temp_i;i<n-1;++i)
        {
            temp = pre[i-1] | ((A[i]*x) | suf[i+1]);
            max0 = max(max0,temp);
        }
        max0 = max(max0, pre[n-2] | (A[n-1]*x));
        cout << max0 << endl;
    }
    else
    {
        unsigned long long ans = A[n-1] * power(x,k);
        for(int i=n-2;i>=0;--i)
            ans |= A[i];
        cout << ans << endl;
    }
    return 0;
}