#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int A[N]; 
int main()
{
	int n;
	cin>>n;

	for(int i=0; i<n; i++)
		cin>>A[i];
	int ans = 1<<30;
	
	for(int bit=0; bit< (1<<(n-1)); bit++)
	{
		int o = 0, x = 0;
		for(int j=0; j<n; j++)
		{
			o |= A[j];
			if(bit>>j & 1 || j == n-1) 	
				x ^= o, o = 0;
		}
		ans = min(ans, x);
	}
	cout<< ans <<endl;
}

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x) cerr << "[" << #x << "]: " << x << "\n";

using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using pl = pair<ll, ll>;

ld const PI = 4*atan((ld)1);

template<int MOD = 998'244'353>
struct Mint
{
	int val;

	Mint() : val(0) {}
	Mint(ll _val) : val((int)(_val % MOD)) { if (val < 0) val += MOD; }

	Mint& operator+= (const Mint &rhs) { val += rhs.val; if (val >= MOD) val -= MOD; return *this; }
	Mint& operator-= (const Mint &rhs) { val -= rhs.val; if (val < 0) val += MOD; return *this; }
	Mint& operator*= (const Mint &rhs) { val = (int)((ll) val * rhs.val % MOD); return *this; }

	friend Mint fpow(Mint x, ll y)
	{
		Mint res = 1;
		for (; y > 0; y >>= 1, x *= x)
		{
			if (y & 1)
				res *= x;
		}
		return res;
	}
	friend Mint inverse(Mint x) { return fpow(x, MOD-2); }
	Mint& operator/= (const Mint &rhs) { return *this *= inverse(rhs); }

	friend Mint operator+ (Mint a, const Mint &b) { return a += b; }
	friend Mint operator- (Mint a, const Mint &b) { return a -= b; }
	friend Mint operator- (Mint a) { return 0 - a; }
	friend Mint operator* (Mint a, const Mint &b) { return a *= b; }
	friend Mint operator/ (Mint a, const Mint &b) { return a /= b; }
	friend ostream& operator<< (ostream &os, const Mint &a) { return os << a.val; }
	friend bool operator== (const Mint &a, const Mint &b) { return a.val == b.val; }
	friend bool operator!= (const Mint &a, const Mint &b) { return a.val != b.val; }
};


const int MAX = 107;

int n;
int w[MAX];
Mint<> dp[MAX][MAX * MAX]; //dp[a][b], pick a items such that the weigh sum is exactly b
Mint<> fact[MAX];

int main()
{
	fastio;

	fact[0] = 1;
	for (int i = 1; i < MAX; ++i)
		fact[i] = i * fact[i-1];


	cin >> n;
	
	int sum = 0;
	for (int i = 0; i < n; ++i)
		cin >> w[i], sum += w[i];

	if (sum & 1)
	{
		cout << 0 << '\n';
		return 0;
	}

	dp[0][0] = 1;
	for (int i = 0; i < n; ++i)
	{
		for (int a = n-1; a >= 0; --a)
		{
			for (int b = 10000; b >= 0; --b)
			{
				dp[a+1][b + w[i]] += dp[a][b];
			}
		}
	}

	Mint<> res = 0;
	for (int i = 1; i <= n; ++i)
	{
		res += dp[i][sum/2] * fact[i] * fact[n-i];
	}
	cout << res << '\n';

	return 0;
}
