You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR. 

Find the maximum possible value of <image> after performing at most k operations optimally.

Input

The first line contains three integers n, k and x (1 ≤ n ≤ 200 000, 1 ≤ k ≤ 10, 2 ≤ x ≤ 8).

The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).

Output

Output the maximum value of a bitwise OR of sequence elements after performing operations.

Examples

Input

3 1 2
1 1 1


Output

3


Input

4 2 3
1 2 4 8


Output

79

Note

For the first sample, any possible choice of doing one operation will result the same three numbers 1, 1, 2 so the result is <image>. 

For the second sample if we multiply 8 by 3 two times we'll get 72. In this case the numbers will become 1, 2, 4, 72 so the OR value will be 79 and is the largest possible result.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;



public final class CF_321_OrGame {

	void log(int[] X){
		int L=X.length;
		for (int i=0;i<L;i++){
			logWln(X[i]+" ");
		}
		log("");
	}


	void log(long[] X){
		int L=X.length;
		for (int i=0;i<L;i++){
			logWln(X[i]+" ");
		}
		log("");
	}
	void log(Object[] X){
		int L=X.length;
		for (int i=0;i<L;i++){
			logWln(X[i]+" ");
		}
		log("");
	}


	void log(Object o){
		logWln(o+"\n");
	}

	void logWln(Object o){
		System.out.print(o);
		//outputWln(o);

	}
	void info(Object o){
		System.out.println(o);
		//output(o);
	}

	void output(Object o){

		outputWln(""+o+"\n");

	}

	void outputWln(Object o){
		// System.out.print(o);

		try {
			out.write(""+ o);
		} catch (Exception e) {

		}
	}

	class Composite{
		int val;
	}

	void solve(){

		int[] cnt=new int[32];
		for (int i=0;i<N;i++){
			int mask=1;
			for (int u=0;u<31;u++){
				if ((a[i]&mask)==mask)
					cnt[u]++;
				mask<<=1;
			}
		}
		boolean first=true;
		int minim=Integer.MAX_VALUE;
		for (int u=30;u>=0;u--){
			if (first){
				if (cnt[u]>0)
					first=false;
			}
			if (!first){
				minim=Math.min(minim, cnt[u]);
			}
		}
		long maxV=0;
		int[] xor=new int[N];
		int max=0;
		int last=0;
		for (int i=N-1;i>=0;i--){
			xor[i]=a[i]|last;
			last=xor[i];
			if (max<a[i])
				max=a[i];
		}
		if (minim>K){
			HashSet<Long>[] list=new HashSet[K+1];
			HashMap<Long,Composite> min=new HashMap<Long,Composite>();
			for (int k=0;k<K;k++)
				list[k]=new HashSet<Long>();
			for (int i=0;i<N;i++){
				for (int k=K-1;k>=0;k--){
					for (long y:list[k]){
						long z;
						long m=1;
						for (int u=1;u+k<=K;u++){
							m*=x;
							z=y|(a[i]*m);
							Composite Z=min.get(z);
							if (Z==null){
								Z=new Composite();
								Z.val=k+1;
								min.put(z, Z);
							} else {
								if (Z.val>k+u){
									list[Z.val].remove(z);
									Z.val=u+k;
									list[u+k].add(z);
								}
							}
						} 

					}
				}
			}
			for (long w:list[K]){
				if ((w|xor[0])>maxV)
					maxV=w|xor[0];
			}
		} else {

			HashSet<Long>[] list=new HashSet[K];
			HashMap<Long,Composite> min=new HashMap<Long,Composite>();
			for (int k=0;k<K;k++)
				list[k]=new HashSet<Long>();
			list[0].add(0L);

			int lenMax=0;
			while (max>0){
				lenMax++;
				max>>=1;
			}
			int lenX=0;
			int X=x;
			while (X>0){
				lenX++;
				X>>=1;
			}
			//	log("lenMax:"+lenMax);
			//	log("lenX:"+lenX);
			long MAX=(1L<<((lenX*K)+lenMax-1))-1;
			//	log("MAX:"+MAX);

			for (int i=0;i<N;i++){
				for (int k=K-1;k>=0;k--){
					HashSet<Long> tmp=new HashSet<Long>();
					for (long y:list[k]){


						if ((y|xor[i])==MAX){
							output(MAX);
							return;
						}

						long z;
						long m=1;
						for (int u=1;u+k<=K;u++){
							m*=x;
							z=y|(a[i]*m);
							if (z>maxV)
								maxV=z;
							if (k+u<K){
								Composite Z=min.get(z);
								if (Z==null){
									Z=new Composite();
									Z.val=k+1;
									min.put(z, Z);
								} else {
									if (Z.val>k+u){
										Z.val=k+u;
										list[k+u].add(z);
									}
								}
							} else {
								if (i+1<N){
									if (maxV<(z|xor[i+1]))
										maxV=z|xor[i+1];
								}
							}
						}
						z=y|a[i];
						tmp.add(z);
					}
					list[k].addAll(tmp);
				}
			}
		}
		output(maxV);
	}

	void test(){
		int NTESTS=1000;
		int VMAX=10000;
		N=5;
		Random r=new Random();
		for (int t=0;t<NTESTS;t++){
			a=new int[N];
	
			for (int i=0;i<N;i++){
				a[i]=r.nextInt(VMAX)+1;
			}
			//log(a);
			x=8;
			K=10;
			long s1=solveStrange();
			long s2=solveSlow();
			if (s1!=s2){
				log("-------ERROR------");
				log(N+" "+K+" "+x);
				log(a);
				log(s1+" "+s2);
				log(s1-s2);
				return;
			}
		}
	}
	
	int ln2(long x){
		int cnt=0;
		while (x>0){
			cnt++;
			x>>=1;
		}
		return cnt;
	}

	long solveStrange(){
		int[] candidates=new int[N];
		int p=0;
		long[] left=new long[N];
		long[] right=new long[N];
		long last;
		last=0;
		for (int i=0;i<N;i++){
			left[i]=last|a[i];
			last=left[i];
		}
		last=0;
		for (int i=N-1;i>=0;i--){
			right[i]=last|a[i];
			last=right[i];
		}
		int highest=-1;
		
		long m=1;
		for (int u=0;u<K;u++){
			m*=x;
		}
		long max=0;
		for (int i=0;i<N;i++){
			long yy=a[i];
			yy*=m;
			if (i>0)
				yy|=left[i-1];
			if (i+1<N)
				yy|=right[i+1];
			if (yy>max) {
				max=yy;
			}
		}
	
		
		//output(max);
		return max;
	}

	long solveSlow(){
		HashSet<Long>[] list=new HashSet[K];
		HashMap<Long,Composite> min=new HashMap<Long,Composite>();
		for (int k=0;k<K;k++)
			list[k]=new HashSet<Long>();
		list[0].add(0L);
		int[] xor=new int[N];
		int max=0;
		int last=0;
		for (int i=N-1;i>=0;i--){
			xor[i]=a[i]|last;
			last=xor[i];
			if (max<a[i])
				max=a[i];
		}
		int lenMax=0;
		while (max>0){
			lenMax++;
			max>>=1;
		}
		int lenX=0;
		int X=x;
		while (X>0){
			lenX++;
			X>>=1;
		}
		//	log("lenMax:"+lenMax);
		//	log("lenX:"+lenX);
		long MAX=(1L<<((lenX*K)+lenMax-1))-1;
		//	log("MAX:"+MAX);
		long maxV=0;
		for (int i=0;i<N;i++){
			/*
			for (int e=0;e<K;e++){
				logWln(list[e].size()+" ");
			}
			log("");
			 */
			for (int k=K-1;k>=0;k--){
				HashSet<Long> tmp=new HashSet<Long>();
				for (long y:list[k]){
					if ((y|xor[i])==MAX){
						output(MAX);
						return MAX;
					}
					long z;
					long m=1;
					for (int u=1;u+k<=K;u++){
						m*=x;
						z=y|(a[i]*m);
						if (z!=y){
							if (z>maxV)
								maxV=z;
							if (k+u<K){
								Composite Z=min.get(z);
								if (Z==null){
									Z=new Composite();
									Z.val=k+1;
									min.put(z, Z);
									list[k+u].add(z);
								} else {
									if (Z.val>k+u){
										Z.val=k+u;
										list[k+u].add(z);
									}
								}
							} else {
								if (i+1<N){
									if (maxV<(z|xor[i+1]))
										maxV=z|xor[i+1];
								}
							}
						}
					}
					z=y|a[i];
					if (z!=y)
						tmp.add(z);
				}
				list[k].addAll(tmp);
			}
		}
		//output(maxV);
		return maxV;
	}

	BufferedWriter out;
	int N,K,x;
	int[] a;




	void process() throws Exception {


		out = new BufferedWriter(new OutputStreamWriter(System.out));
		InputReader reader=new InputReader(System.in);

		/*
		long X=6862;
		X*=Math.pow(8, 10);
		X|=6126;
		X|=6214;
		X|=1624;
		X|=3712;
		log("X:"+X);
		
		test();
	*/
	
		
		N=reader.readInt();
		K=reader.readInt();
		x=reader.readInt();
		a=new int[N];
		for (int i=0;i<N;i++){
			a[i]=reader.readInt();

		}
		output(solveStrange());
	
		 
		try {
			out.close();
		}
		catch (Exception e){}


	}



	public static void main(String[] args) throws Exception {
		CF_321_OrGame J=new CF_321_OrGame();

		J.process();


	}


	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}


		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res=new StringBuilder();
			do {
				res.append((char)c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}




		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

} 