#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define add(a,b) a=((a)+(b))%mod
#define mod 998244353
#define Mod 998244351
#define ll long long
//#define file
using namespace std;

int n,i,j,k,l,sum;
int a[101];
int f[101][10001];
ll jc[101];
ll ans;

ll qpower(ll a,int b) {ll ans=1; while (b) {if (b&1) ans=ans*a%mod;a=a*a%mod;b>>=1;} return ans;}

int main()
{
	#ifdef file
	freopen("b.in","r",stdin);
	#endif
	
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]),sum+=a[i];
	if (sum&1) {printf("0\n");return 0;}
	f[0][0]=1;
	fo(i,1,n)
	{
		fd(j,i-1,0)
		{
			fo(k,0,10000)
			if (f[j][k])
			add(f[j+1][k+a[i]],f[j][k]);
		}
	}
	
	sum/=2;
	jc[0]=1;
	fo(i,1,n) jc[i]=jc[i-1]*i%mod;
	fo(i,1,n) add(ans,jc[i]*jc[n-i]%mod*f[i][sum]);
	printf("%lld\n",(ans+mod)%mod);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  int64_t A[n];
  for(int i=0; i<n; i++) cin >> A[i];
  if(n==1){
    cout << A[0] << endl;
  	return 0;
  }else if(n==2){
  	cout << (A[0]^A[1]) << endl;
  }
  
  int64_t ans = 1 << 30;
  for(int64_t i=1; i<(1<<(n-1)); i++){
  	int j=0;
    int64_t or_result = A[0], tmp=0;
    while(j<n-1){
      if(i>>j&1){
      	tmp = tmp ^ or_result;
        or_result = A[j+1];
      }else{
      	or_result = or_result | A[j+1];
      }
      j++;
    }
    tmp = tmp ^ or_result;
    if(ans>tmp){
      ans = tmp;
    }
    if(ans==0){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
  