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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	ll res=0;
	set<ll> s;
	set<ll> w;
	cin >> n;
	for (int i =0; i < n; i++) {
		ll tmp;
		cin >> tmp;
		s.insert(tmp);
		}

	for (auto& x: s) {
		res |= x;
		set<ll>wt(w);
		for (auto& xx: wt) {
			ll c = xx + x;
			if (w.count(c)) {
				//cout << "   skip" << xx << "\n";
					continue;	
				}
			//cout << "push" << c << "\n";
			w.insert(c);
			res |= c;
			}
		//cout << "push" << x << "\n";
		w.insert(x);
	}
	cout << res << "\n";

    return 0;
}
