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


int main()
{
    int N, K;
    int storage;
    cin>>N>>K;
    int ar;
    for(int i = 0; i<N; i++){
    int calc = ar;
    cin>>ar;
    calc = calc | ar;
    if(calc % K == 0){
        storage = storage % calc;
        storage = calc;
    }
    /*cout<<"Value of storage = "<<storage<<endl;
    cout<<"Value of calc = "<<calc<<endl;
    cout<<"Value of ar = "<<ar<<endl;*/
    }
    return 0;
}
