You are given n numbers a_1, a_2, ..., a_{n}. 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 $1$ 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 a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9).


-----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 $1|1|2 = 3$. 

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.

Difficulty: competition

Starter code:

Solutions:
class Ortree():
    def __init__(self, n, As):
        size = 1
        while n > size:
            size *= 2
        self.size = size
        data = [0] * size + As[:] + [0] * (size - n)
        for idx in range(self.size - 1, 0, -1):
            idx2 = idx << 1
            data[idx] = data[idx2] | data[idx2 + 1]
        self.data = data
    
    def update(self, idx, val):
        pos = idx + self.size
        self.data[pos] = val
        pos >>= 1
        while pos:
            pos2 = pos << 1
            self.data[pos] = self.data[pos2] | self.data[pos2 + 1]
            pos >>= 1
        return self.data[1]


def solve(n, k, x, As):
    As.sort(reverse= True)
    xk = x**k
    if n == 1:
        As[0] *= xk
        return As[0]
    if is_simplecase(xk, As):
        As[0] *= xk
        return cumor(As)
    return complexcase(n, xk, As)
    

def cumor(As):
    result = 0
    for a in As:
        result |= a
    return result

def is_simplecase(xk, As):
    len0 = len(bin(As[0] * xk))
    len1 = len(bin(As[1] * xk))
    return len0 > len1

def complexcase(n, xk, As):
    len0 = len(bin(As[0] * xk))
    for i, a in enumerate(As[1:], 1):
        if len(bin(a * xk)) < len0:
            end = i
            rest = cumor(As[end:])
            break
    else:
        end = n
        rest = 0
    ortree = Ortree(end, As[:end])
    record = rest
    for i in range(end):
        score = ortree.update(i, As[i] * xk) | rest
        if record < score:
            record = score
        ortree.update(i, As[i])
    return record

n, k, x = map(int, input().split())
As = list(map(int, input().split()))
print(solve(n, k, x, As))

#!/usr/bin/env python
# 579D_or.py - Codeforces.com/problemset/problem/579/D by Sergey 2015

import unittest
import sys

###############################################################################
# Or Class (Main Program)
###############################################################################


class Or:
    """ Or representation """

    def __init__(self, test_inputs=None):
        """ Default constructor """

        it = iter(test_inputs.split("\n")) if test_inputs else None

        def uinput():
            return next(it) if it else sys.stdin.readline().rstrip()

        # Reading single elements
        [self.n, self.k, self.x] = list(map(int, uinput().split()))

        # Reading a single line of multiple elements
        self.nums = list(map(int, uinput().split()))

        self.cnt = [0] * 100
        for n in self.nums:
            i = 0
            while n != 0:
                if n % 2:
                    self.cnt[i] += 1
                n >>= 1
                i += 1

        self.nmax = 0
        for n in self.nums:
            cur_cnt = list(self.cnt)
            i = 0
            nn = n
            while n != 0:
                if n % 2:
                    cur_cnt[i] -= 1
                n >>= 1
                i += 1
            n = nn * self.x ** self.k
            i = 0
            while n != 0:
                if n % 2:
                    cur_cnt[i] += 1
                n >>= 1
                i += 1

            k = 0
            for i in range(len(cur_cnt)):
                if cur_cnt[i] > 0:
                    k += 1 << i

            if k > self.nmax:
                self.nmax = k

    def calculate(self):
        """ Main calcualtion function of the class """

        result = self.nmax

        return str(result)

###############################################################################
# Unit Tests
###############################################################################


class unitTests(unittest.TestCase):

    def test_single_test(self):
        """ Or class testing """

        # Constructor test
        test = "3 1 2\n1 1 1"
        d = Or(test)
        self.assertEqual(d.n, 3)
        self.assertEqual(d.k, 1)
        self.assertEqual(d.x, 2)
        self.assertEqual(d.nums, [1, 1, 1])

        # Sample test
        self.assertEqual(Or(test).calculate(), "3")

        # Sample test
        test = "4 2 3\n1 2 4 8"
        self.assertEqual(Or(test).calculate(), "79")

        # Sample test
        test = ""
        # self.assertEqual(Or(test).calculate(), "0")

        # My tests
        test = ""
        # self.assertEqual(Or(test).calculate(), "0")

        # Time limit test
        # self.time_limit_test(5000)

    def time_limit_test(self, nmax):
        """ Timelimit testing """
        import random
        import timeit

        # Random inputs
        test = str(nmax) + " " + str(nmax) + "\n"
        numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
        test += "\n".join(numnums) + "\n"
        nums = [random.randint(1, 10000) for i in range(nmax)]
        test += " ".join(map(str, nums)) + "\n"

        # Run the test
        start = timeit.default_timer()
        d = Or(test)
        calc = timeit.default_timer()
        d.calculate()
        stop = timeit.default_timer()
        print(("\nTimelimit Test: " +
              "{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
              format(stop-start, calc-start, stop-calc)))

def __starting_point():

    # Avoiding recursion limitaions
    sys.setrecursionlimit(100000)

    if sys.argv[-1] == "-ut":
        unittest.main(argv=[" "])

    # Print the result string
    sys.stdout.write(Or().calculate())

__starting_point()

n, k, x = list(map(int, input().split()))
a = list(map(int, input().split()))

pref = [0 for el in a]
suff = [0 for el in a]

pref[0] = a[0]
for i in range(1, len(a)):
    pref[i] = pref[i-1] | a[i]

suff[-1] = a[-1]
for i in range(len(a)-2, -1, -1):
    suff[i] = suff[i+1] | a[i]

if n == 1:
    print(a[0]*x**k)
    return

sol = max((a[0]*x**k) | suff[1], pref[-2] | (a[-1]*x**k))
for i in range(1, len(a)-1):
    sol = max(sol, pref[i-1] | (a[i]*x**k) | suff[i+1])

print(sol)


__author__ = 'kitkat'
import sys

#sys.stdin = open("in.txt")
try:
    while True:
        n, k, x = list(map(int, input().split(" ")))
        val = [0] + list(map(int, input().split(" ")))
        res = 0
        L = [0 for i in range(200003)]
        R = [0 for i in range(200003)]
        for i in range(1, n+1, 1):
            L[i] = L[i-1] | val[i]
            R[n-i+1] = R[n-i+2] | val[n-i+1]
        for i in range(1, n+1, 1):
            for j in range(k):
                val[i] *= x
        for i in range(1, n+1, 1):
            res = max(res, L[i-1] | R[i+1] | val[i])
        print(res)
except EOFError:
    pass


def pw(a, x, k):
    if a == 0:
        return 0;
    ans = a;
    while (k > 0):
        ans *= x;
        k = k - 1;
    return ans;
n, k, x = list(map(int, input().split()));
a = list(map(int, input().split()));
lft = [];
lft.append(0);
for val in a:
    lft.append(val);
lft.append(0);
rht = [];
for val in lft:
    rht.append(val);
for i in range(1, len(lft)):
    lft[i] = lft[i] | lft[i - 1];
#print (lft);
for i in range(len(rht) - 2, -1, -1):
    rht[i] = rht[i] | rht[i + 1];
#print (rht);
ans = 0;
for i in range (1, len(lft) - 1):
    if(ans < (lft[i - 1] | pw(a[i - 1], x, k) | rht[i + 1])):
        ans = lft[i - 1] | pw(a[i - 1], x, k) | rht[i + 1];
print (ans);


#!/usr/bin/env python
# 579D_or.py - Codeforces.com/problemset/problem/579/D by Sergey 2015

import unittest
import sys

###############################################################################
# Or Class (Main Program)
###############################################################################


class Or:
    """ Or representation """

    def __init__(self, test_inputs=None):
        """ Default constructor """

        it = iter(test_inputs.split("\n")) if test_inputs else None

        def uinput():
            return next(it) if it else input().rstrip()

        # Reading single elements
        [self.n, self.k, self.x] = list(map(int, uinput().split()))

        # Reading a single line of multiple elements
        self.nums = list(map(int, uinput().split()))

        self.cnt = [0] * 100
        for n in self.nums:
            i = 0
            while n != 0:
                if n % 2:
                    self.cnt[i] += 1
                n >>= 1
                i += 1

        self.nmax = 0
        for n in self.nums:
            cur_cnt = list(self.cnt)
            i = 0
            nn = n
            while n != 0:
                if n % 2:
                    cur_cnt[i] -= 1
                n >>= 1
                i += 1
            n = nn * self.x ** self.k
            i = 0
            while n != 0:
                if n % 2:
                    cur_cnt[i] += 1
                n >>= 1
                i += 1

            k = 0
            for i in range(len(cur_cnt)):
                if cur_cnt[i] > 0:
                    k += 1 << i

            if k > self.nmax:
                self.nmax = k

    def calculate(self):
        """ Main calcualtion function of the class """

        result = self.nmax

        return str(result)

###############################################################################
# Unit Tests
###############################################################################


class unitTests(unittest.TestCase):

    def test_single_test(self):
        """ Or class testing """

        # Constructor test
        test = "3 1 2\n1 1 1"
        d = Or(test)
        self.assertEqual(d.n, 3)
        self.assertEqual(d.k, 1)
        self.assertEqual(d.x, 2)
        self.assertEqual(d.nums, [1, 1, 1])

        # Sample test
        self.assertEqual(Or(test).calculate(), "3")

        # Sample test
        test = "4 2 3\n1 2 4 8"
        self.assertEqual(Or(test).calculate(), "79")

        # Sample test
        test = ""
        # self.assertEqual(Or(test).calculate(), "0")

        # My tests
        test = ""
        # self.assertEqual(Or(test).calculate(), "0")

        # Time limit test
        # self.time_limit_test(5000)

    def time_limit_test(self, nmax):
        """ Timelimit testing """
        import random
        import timeit

        # Random inputs
        test = str(nmax) + " " + str(nmax) + "\n"
        numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
        test += "\n".join(numnums) + "\n"
        nums = [random.randint(1, 10000) for i in range(nmax)]
        test += " ".join(map(str, nums)) + "\n"

        # Run the test
        start = timeit.default_timer()
        d = Or(test)
        calc = timeit.default_timer()
        d.calculate()
        stop = timeit.default_timer()
        print(("\nTimelimit Test: " +
              "{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
              format(stop-start, calc-start, stop-calc)))

def __starting_point():

    # Avoiding recursion limitaions
    sys.setrecursionlimit(100000)

    if sys.argv[-1] == "-ut":
        unittest.main(argv=[" "])

    # Print the result string
    sys.stdout.write(Or().calculate())

__starting_point()

import sys

n, k, x = [int(x) for x in sys.stdin.readline().split()]

a = [int(x) for x in sys.stdin.readline().split()]

tl = 0
l = [0] * (n + 1)
for i in range(n - 1, -1, -1):
    tl |= a[i]
    l[i] = tl

ans = 0
tr = 0
for i in range(0, n):
    ta = tr | a[i] * x ** k | l[i + 1]
    ans = ans if ans > ta else ta
    tr |= a[i]

print(ans)


def solve(n,k,x,a):
    s = 0
    prefix = [0] * (n+10)
    suffix = [0] * (n+10)
    a.append(0)
    a.insert(0,0)
    m = pow(x,k)
    for i in range(1,n+1):
        prefix[i] = prefix[i-1] | a[i]
    for i in range(n, 0, -1):
        suffix[i] = suffix[i+1] | a[i]
    for i in range(1,n+1):
        s = max(s, prefix[i-1] | (a[i]*m) | suffix[i+1])
    return s

def main(infile, outfile):
    n,k,x = list(map(int,infile.readline().split()))
    a = list(map(int,infile.readline().split()))
    outfile.write(str(solve(n,k,x,a)) + '\n')

def __starting_point():
    from sys import stdin, stdout
    main(stdin, stdout)

__starting_point()

def main():
    n, k, x = list(map(int, input().split()))
    aa = list(map(int, input().split()))
    x, lo, u = x ** k, [0] * n, 0
    for i, a in enumerate(aa):
        lo[i] = u
        u |= a
    hi, u = [], 0
    for a in reversed(aa):
        hi.append(u)
        u |= a
    hi.reverse()
    for i, u, a, v in zip(list(range(n)), lo, aa, hi):
        aa[i] = a * x | u | v
    print(max(aa))


def __starting_point():
    main()

__starting_point()

x, n, k = [int(x) for x in input().split()]
lista = [int(x) for x in input().split()]
acumuladaL = []
acumuladaR = []
mult = k ** n

cont = 0
for i in lista:
    cont |= i
    acumuladaL.append(cont)
cont = 0
for i in lista[::-1]:
    cont |= i
    acumuladaR.append(cont)
if len(lista) == 1:
    print(lista[0] * mult)
elif len(lista) == 2:
    acumuladaR = acumuladaR[::-1]
    maximo = max([lista[0] * mult | acumuladaR[1],
                  lista[-1] * mult | acumuladaL[-2]])
    print(maximo)
else:
    maximo = max([lista[0] * mult | acumuladaR[1],lista[-1] * mult | acumuladaL[-2]])
    acumuladaR = acumuladaR[::-1]

    for i in range(1, len(lista) - 1):
        var = lista[i] * mult | acumuladaR[i + 1] | acumuladaL[i - 1]
        if maximo < var:
            maximo = var
    print(maximo)


x, n, k = [int(x) for x in input().split()]
lista = [int(x) for x in input().split()]
acumuladaL = []
acumuladaR = []
mult = k ** n

cont = 0
for i in lista:
    cont |= i
    acumuladaL.append(cont)
cont = 0
for i in lista[::-1]:
    cont |= i
    acumuladaR.append(cont)
if len(lista) == 1:
    print(lista[0] * mult)
elif len(lista) == 2:
    acumuladaR = acumuladaR[::-1]
    maximo = max([lista[0] * mult | acumuladaR[1],
                  lista[-1] * mult | acumuladaL[-2]])
    print(maximo)
else:
    maximo = max([lista[0] * mult | acumuladaR[1],lista[-1] * mult | acumuladaL[-2]])
    acumuladaR = acumuladaR[::-1]

    for i in range(1, len(lista) - 1):
        var = lista[i] * mult | acumuladaR[i + 1] | acumuladaL[i - 1]
        if maximo < var:
            maximo = var
    print(maximo)

# 1500336849347


import sys
import math

[n,k,x] = [int(i) for i in sys.stdin.readline().rstrip('\n').split()]
nums = [int(i) for i in sys.stdin.readline().rstrip('\n').split()]


offset = 1
for i in range(k):
	offset = offset*x

leftor = [0]
for i in nums[:-1]:
	leftor.append(leftor[-1] | i)
rightor = [0]
for i in range(len(nums)-1,0,-1):
	rightor.append(rightor[-1] | nums[i])
ans = []
for i in range(len(nums)):
	ans.append(leftor[i] | ((nums[i]*offset) | rightor[n-i-1]))

sys.stdout.write(str(max(ans))+'\n')


n,k,x = map( int,input().split() )
*Arr, = map( int,input().split() )

Prfx = [0]*(n+2)
Sffx = [0]*(n+2)

for i in range(0,n):
    Prfx[i+1] = Prfx[i]|Arr[i]
    Sffx[n-i-1] = Sffx[n-i]|Arr[n-i-1]
now = x**k
Res = 0
for i in range(0,n):
    Res = max( Prfx[i]|(Arr[i]*now)|Sffx[i+1],Res );
print(Res)

n,k,x=list(map(int,input().split()))

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

a=[0]*n

b=[0]*n

for i in range(1,n): a[i]=a[i-1]|l[i-1]

for i in range(1,n): b[n-i-1]=b[-i]|l[-i]

nom=0

for i in range(1,n):

    if l[nom]*(x**k)|a[nom]|b[nom]<l[i]*(x**k)|a[i]|b[i]: nom=i

l[nom]*=x**k

print(l[nom]|a[nom]|b[nom])





# Made By Mostafa_Khaled


import math
a=list(map(int,input().split()))
n=a[0]
k=a[1]
x=a[2]
a=list(map(int,input().split()))
b=[None]*n
c=[None]*n
b[0]=a[0]
mul=1
c[n-1]=a[n-1]
for i in range(k):
    mul*=x
if n==1:
    print(mul*a[0])
else:
    for i in range(1,n):
        b[i]=b[i-1]|a[i]
    for i in range(n-2,-1,-1):
        c[i]=c[i+1]|a[i]
    ans=max(a[0]*mul|c[1],a[n-1]*mul|b[n-2])
    for i in range(1,n-1):
        ans=max(ans,a[i]*mul|b[i-1]|c[i+1])
    print(ans)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 14 21:25:50 2019

@author: pawangoyal
"""
input_1=input()
input_1=input_1.split()
n = int(input_1[0])
k = int(input_1[1])
x = int(input_1[2])

a=input()
a=a.split()
a=[int(x) for x in a]
maximum=0
prefix=[]
suffix=[]

prefix_or = 0
suffix_or = 0

for i in range(n):
    prefix_or = prefix_or|a[i]
    prefix.append(prefix_or)

for i in range(n-1,-1,-1):
    suffix_or = suffix_or|a[i]
    suffix.append(suffix_or)
 
or_bit=0

if n ==1 :
    or_bit=a[0]*(x**k)
else:
    for i in range(n):
        if i == 0:
            or_bit=max(or_bit,(a[0]*(x**k)|suffix[n-2]))
        elif i == (n-1):
            or_bit=max(or_bit,(a[n-1]*(x**k)|prefix[n-2]))
        else:
            or_bit=max(or_bit,(a[i]*(x**k)|prefix[i-1]|suffix[n-2-i]))
   
    
print(or_bit)




def __starting_point():
    n, k, p = map(int, input().split())
    numbers = list(map(int, input().split()))
    # initialize vectors x, y with 0 for n + 10 positions
    x = [0] * (n + 10)
    y = [0] * (n + 10)
    # raise to power
    p = p ** k
    maxi = 0
    for i in range(n):
        x[i + 1] = numbers[i] | x[i]
    for j in range(n, -1, -1):
        y[j - 2] = numbers[j - 1] | y[j - 1]
    for i in range(n):
        if maxi < x[i] | numbers[i] * p | y[i]:
            maxi = x[i] | numbers[i] * p | y[i]
    print(maxi)
__starting_point()

# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/10/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
import itertools


def blen(val):
    s = 0
    while val > 0:
        s += 1
        val >>= 1
    
    return s


def solve(N, K, X, A):
    left = [0 for _ in range(N)]
    right = [0 for _ in range(N)]
    
    for i, v in enumerate(A):
        left[i] = (left[i-1] if i-1 >= 0 else 0) | v
    for i in range(N-1, -1, -1):
        right[i] = (right[i+1] if i+1 < N else 0) | A[i]
    
    ans = 0
    for i, v in enumerate(A):
        a = left[i-1] if i-1 >= 0 else 0
        b = right[i+1] if i+1 < N else 0
        ans = max(ans, a | b | (v * X**K))
    
    return ans
    
    

N, K, X = map(int, input().split())
A = [int(x) for x in input().split()]
print(solve(N, K, X, A))

# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/10/20

a simple conclusion is that we should multiple only one v with x K times

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List


def solve(N, K, X, A):
    prefix = [0 for _ in range(N)]
    suffix = [0 for _ in range(N)]
    
    for i, v in enumerate(A):
        prefix[i] = (prefix[i-1] if i-1 >= 0 else 0) | v
    for i in range(N-1, -1, -1):
        suffix[i] = (suffix[i+1] if i+1 < N else 0) | A[i]
    
    ans = 0
    for i, v in enumerate(A):
        a = prefix[i-1] if i-1 >= 0 else 0
        b = suffix[i+1] if i+1 < N else 0
        ans = max(ans, a | b | (v * X**K))
    
    return ans
    

N, K, X = map(int, input().split())
A = [int(x) for x in input().split()]
print(solve(N, K, X, A))

import sys
class IoTool:  # a tool for input redirection 
    DEBUG = 0
    def _reader_dbg():
        with open('./input.txt', 'r') as f:
            lines = f.readlines()
        for l in lines: yield l.strip() 
    def _reader_oj():  
        return iter(sys.stdin.read().split('\n'))
    reader = _reader_dbg() if DEBUG else _reader_oj()
    def read(): return next(IoTool.reader)

input = IoTool.read

def main():
    n, k, x = list(map(int, input().split()))
    a = list(map(int, input().split()))
    mul = 1
    for i in range(k): mul *= x
    if n == 1:
        print(a[0] * mul)
        return
    pre, tail = [0] * n, [0] * n
    pre[0] = a[0]
    tail[n-1] = a[n-1]
    
    for i in range(1, n): pre[i] = pre[i-1] | a[i]
    for i in range(n-2, -1, -1): tail[i] = tail[i+1] | a[i]
    answer = max((pre[0]*mul) | tail[1], pre[n-2]|(tail[n-1]*mul))
    for i in range(1, n-1):
        answer = max(answer, (a[i] * mul) | pre[i-1] | tail[i+1])
    print(answer)


def __starting_point():
    main()

__starting_point()

n,k,x = list(map(int,input().split()))
lis = list(map(int,input().split()))
pre=[0]*(n+2)
pos=[0]*(n+2)
ans=0
m=x**k
for i in range(1,n):
    pre[i]=pre[i-1]|lis[i-1]
for i in range(n,0,-1):
    pos[i]=pos[i+1]|lis[i-1]
for i in range(1,n+1):
    ans=max(ans,pre[i-1]|lis[i-1]*m|pos[i+1])
print(ans)    




n,k,x=list(map(int,input().split()))
a=list(map(int,input().split()))
c=x**k
pr=[0]
su=[0]
b=0
for i in range(n-1):
    b=a[i]|b
    pr.append(b)
b=0
for i in range(n-1,0,-1):
    b=a[i]|b
    su.append(b)
su=su[::-1]
d=[]
for i in range(n):
    d.append(pr[i]|a[i]*c|su[i])
print(max(d))

import sys
import math
#from queue import *
#import random
#sys.setrecursionlimit(int(1e6))
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(list(map(int,input().split())))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n,k,x=invr()
ara=inara()
ara.append(0)
ara.reverse()
ara.append(0)
ara.reverse()

mul=int(math.pow(x,k))

pref=[0]*(n+2)

for i in range(1,n+1):
	pref[i]=pref[i-1]|ara[i]

suff=[0]*(n+2)

for i in range(n,0,-1):
	suff[i]=suff[i+1]|ara[i]
	
ans=0

for i in range(1,n+1):
	ans=max(ans,pref[i-1]|ara[i]*mul|suff[i+1])

print(ans)


import sys
import math
#from queue import *
#import random
#sys.setrecursionlimit(int(1e6))
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(list(map(int,input().split())))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n,k,x=invr()
ara=inara()
ara.append(0)
ara.reverse()
ara.append(0)
ara.reverse()

mul=int(math.pow(x,k))

pref=[0]*(n+2)

for i in range(1,n+1):
	pref[i]=pref[i-1]|ara[i]

suff=[0]*(n+2)

for i in range(n,0,-1):
	suff[i]=suff[i+1]|ara[i]
	
ans=0

for i in range(1,n+1):
	ans=max(ans,pref[i-1]|ara[i]*mul|suff[i+1])

print(ans)