#include<bits/stdc++.h>
#include "cmath"
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inf (1<<30)
#define linf 1e18
#define ninf -1e9
#define fore(i, r) for(int i = 1; i <= int(r); i++)
#define loop(i,r) for(int i = 0; i < int(r) ; i++)
#define loop1(i,r) for(int i=1;i<=r;i++)
#define looplr(i,l,r) for(int i=l;i<=r;i++)
#define rloop(i,r) for(int i=r-1;i>=0;i--)
#define min3(x1, x2, x3) (x3 > min(x1, x2) ? min(x2, x1) : x3)
#define max3(x1, x2, x3) (x3 < max(x1, x2) ? max(x1, x2) : x3)
#define sz(a) int((a).size())
#define vi vector< int >
#define vl vector<long long int>
#define vpi vector<pair<int, int> >
#define vpl vector<pair<long long int, long long int> >
#define pb push_back
#define umi unordered_map<int , int>
#define umc unordered_map<char , int>
#define uml unordered_map<long long int , long long int>
#define mpi map<int, int>
#define sti set<int>
#define stl set<long long int>
#define ff first
#define ss second
#define len(x) (int)x.length()
#define ctn continue
#define brk break
#define ub(i,x) upper_bound(i.begin(), i.end(),x)
#define lb(i,x) lower_bound(i.begin(), i.end(),x)
#define ump unordered_map
#define str string
#define memn1(x) memset(x,-1,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define mem0(x) memset(x,0,sizeof(x))
#define rtn return
#define srt(x) sort(all(x))
#define srtgi(x) sort(all(x), greater<int>())
#define srtgl(x) sort(all(x), greater<ll>())
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define nline cout<< "\n"
#define chngl "\n"
#define takei(input) scanf("%d",&input)
#define takel(input) scanf("%lld",&input)
#define pll pair<long long int, long long int>
#define putyes printf("Yes\n")
#define putno printf("No\n")
#define sid int
const int  mod = 1e9 + 7;

using namespace std;

const int N = 1e6 + 5;
int prime[N];

void calPrime() {
	for (int i = 1; i <= 1000000; i++) prime[i] = 1;
	for (int i = 2; i * i <= 1e6 + 1; i++) {
		if (prime[i] == -1) ctn;
		prime[i] = 1;
		for (int j = 2 * i; j <= 1e6 + 1; j +=  i) {
			prime[j] = -1;
		}
	}

}

int pow2(int expo) {
	int val = 1;
	int pp = 1;
	while (pp <= expo) {
		val = ((val % 1000003 ) * 2) % 1000003 ;
		pp++;
	}
	return val % 1000003;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	//calPrime();
	int tme = 1;
	//cin >> tme;
	while (tme--) {
		int n; cin >> n;
		vi a(n);
		loop(i, n) cin >> a[i];
		int ans = inf;
		//cout << inf << endl;
		loop(mask, 1 << (n - 1)) {
			int xored = 0;
			int ored = 0;
			loop(i, n ) {
				ored |= a[i];
				if (i == n - 1  || mask & (1 << i)) {
					xored ^= ored;
					ored = 0;
				}
			}
			ans = min(ans, xored);
		}
		cout << ans;
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int fpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1) ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int a=0,b=n,c=m+n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		b=(b+a);
	}
	int ans=1;
	for(int i=1;i<=b;i++){
		ans=1ll*ans*(c-i+1)%mod;
		ans=1ll*ans*fpow(i,mod-2)%mod;
	}
	printf("%d",ans);
 } 