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

typedef long long ll;
int main()
{
    cin.tie(NULL);
    ll N, K;
    ll storage;
    ll calc;
    cin>>N>>K;
    ll ar;
    K = K-1;
    for(ll i = 0; i<N; i++){
    cin>>ar;
     calc = ar;
    calc = calc | ar;
    if(calc % K == 0){
        storage = storage & calc;
        storage = calc;}
    }
    cout<<storage<<endl;
    return 0;
}
