#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;
int main()
{

    ll N, K;
    ll storage;
    ll calc;
    cin>>N>>K;
    ll ar;
    for(ll i = 0; i<N; i++){
    cin>>ar;
     calc = ar;
    calc = calc | ar;
        storage = storage & calc;
        storage = calc;

}
    cout<<storage<<endl;
    return 0;
}
