#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int, int> >
#define vpll vector <pair <long long, long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vb vector <bool>
#define vvb vector <vb>
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MANX MAXN
#define itn int
#define dbg(x); {cout << #x << "=" << x << ", ";}
#define in(x); { for (auto &to : x) cin >> to;}
#define out(x); { for (auto &to : x) cout << to << " "; cout << '\n'; }

const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const int mod1 = 1e9+7;
const int mod2 = 1e9+21;

void solve()
{
    int n;
    cin>>n;
    ll need;
    cin>>need;
    vector <int>a(n);
    in(a);
    // sum==X (mod%k)
    vector <vector <vi> > dp(n+1,vvi(n+1,vi(n+1,-INF)));
    for (int i=1;i<=n;i++)
    {
        dp[i][0][0]=0;
    }
    for (auto to:a)
    {
        for (int total=1;total<=n;total++)
        {
            for (int got=total-1;got>=0;got--)
            {
                for (int rem=0;rem<total;rem++)
                {
                    if (dp[total][got][rem]==-INF)
                        continue;
                    dp[total][got+1][(rem+to)%total]=max(dp[total][got+1][(rem+to)%total],dp[total][got][rem]+to);
                }
            }
        }
    }
    ll ans=INFLL;
    for (int total=1;total<=n;total++)
    {
        if (dp[total][total][need%total]==-INF)
            continue;
//        cout<<need%total<<" "<<(need-dp[total][total][need%total])/total<<" "<<dp[total][total][need%total]<<" "<<total<<'\n';
        ans=min(ans,(need-dp[total][total][need%total])/total);
    }
    cout<<ans<<'\n';
}

int main() {
    #ifdef Mip182
    freopen("a.in", "r", stdin);
    #else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #endif
    int _t;
    _t=1;
//    cin>>_t;
    while (_t--)
        solve();
    #ifdef Mip182
    cout<<'\n'<<"Time : "<<(double)(clock())/CLOCKS_PER_SEC<<'\n';
    #endif
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
int main() {
    int n;
    int ans = 1 << 30;
    cin >> n;

    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A.at(i);
    }

    for(int bit = 0; bit < (1 << (n-1)); bit++){
        int index = 0;
        int tmp = 0;
        vector<int> B(n, 0);

        for(int i = 0; i < n; i++){
            if(((bit >> (i-1)) & 1) && (i > 0)){
                index++;
            }
            B[index] |= A[i];
        }

        for(int i = 0; i <= index; i++){
            tmp ^= B[i];
        }

        ans = min(tmp, ans);
    }

    cout << ans << endl; 
}