//#pragma GCC optimize("Ofast")
using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <map>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <math.h>
#include <chrono>
#include <cctype>
#include <random>

#ifdef _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

#ifdef _DEBUG
const int MAX_POW = 4;
#else
const int MAX_POW = 21;
#endif

const int MAX_N = 1 << MAX_POW;

typedef long long ll;
using pll = pair<ll, ll>;

const double delta = 1e-8;
const long long mod = 1e9 + 7;
const int magic_const = 1e9;
const ll INF = 3e18;
const ll BIG_DT = 1e12;

mt19937 gen(54323244234);

ll modoper(ll x)
{
	return ((x % mod) + mod) % mod;
}

ll gcd(ll x, ll y)
{
	return y == 0 ? x : gcd(y, x % y);
}

ll get_rand(ll x)
{
	return (gen() % x + x) % x;
}

template <typename T>
void sort(vector<T>& x)
{
	sort(x.begin(), x.end());
}

template <typename T>
void reverse(vector<T>& x)
{
	reverse(x.begin(), x.end());
}

bool check(int x)
{
	vector<int>a(10, 0);

	while (x > 0)
	{
		int now = x % 10;
		a[now]++;
		if (a[now] > 1)
			return false;
		x /= 10;
	}
	return true;
}

ll bin_pow(ll x, ll pow)
{
	if (pow == 0)
		return 1;
	if (pow & 1)
	{
		return (bin_pow(x, pow - 1) * x) % mod;
	}
	else
	{
		ll tmp = bin_pow(x, pow / 2);
		return (tmp * tmp) % mod;
	}
}

vector<ll>get_primes(ll x)
{
	vector<ll>answer;
	for (ll i = 2; i * i <= x; i++)
	{
		if (x % i == 0)
		{
			answer.push_back(i);
			while (x % i == 0)
				x /= i;
		}
	}
	if (x != 1)
		answer.push_back(x);
	return answer;
}

int max_x, max_y, n;

vector<int>a;

vector<pair<int, int>>fact_t(MAX_N, { -1, -1 });
vector<int>reverse_t(MAX_N, -1);

void nullify(int&x, pair<int, int>&a)
{
	if (a.first == x || a.second == x)
	{
		x = -1;
	}
}

bool insert_to_pair(int x, pair<int, int>&ax)
{
	nullify(x, ax);
	if (x > ax.first)
	{
		ax.second = ax.first;
		ax.first = x;
		return true;
	}
	if (x > ax.second)
	{
		ax.second = x;
		return true;
	}
	return false;
}

void merge_pairs(pair<int, int>& f, pair<int, int>s)
{
	insert_to_pair(s.first, f);
	insert_to_pair(s.second, f);
}

void solve()
{
	int n;
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	for (int i = n - 1; i >= 0; i--)
	{
		insert_to_pair(i, fact_t[a[i]]);
	}

	for (int i = MAX_N - 1; i > 0; i--)
	{
		for (int j = 0; j < MAX_POW; j++)
		{
			if (i & (1 << j))
			{
				auto new_bm = i - (1 << j);
				merge_pairs(fact_t[new_bm], fact_t[i]);
			}
		}
	}

	auto answer = 0;

	for (int i = 0; i < n - 2; i++)
	{
		auto new_bm = MAX_N - 1 - a[i];

		auto result_bm = 0;
		for (int j = MAX_POW - 1; j >= 0; j--)
		{
			if (new_bm & (1 << j))
			{
				auto new_result_bm = result_bm | (1 << j);
				if (i < fact_t[new_result_bm].second)
				{
					result_bm = new_result_bm;
				}
			}
		}

		answer = max(answer, a[i] | result_bm);
	}
	cout << answer << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand(58164);

	solve();

	return 0;
}


//#pragma GCC optimize("Ofast")
using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <map>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <math.h>
#include <chrono>
#include <cctype>
#include <random>

#ifdef _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

#ifdef _DEBUG
const int MAX_POW = 4;
#else
const int MAX_POW = 21;
#endif

const int MAX_N = 1 << MAX_POW;

typedef long long ll;
using pll = pair<ll, ll>;

const double delta = 1e-8;
const long long mod = 1e9 + 7;
const int magic_const = 1e9;
const ll INF = 3e18;
const ll BIG_DT = 1e12;

mt19937 gen(54323244234);

ll modoper(ll x)
{
	return ((x % mod) + mod) % mod;
}

ll gcd(ll x, ll y)
{
	return y == 0 ? x : gcd(y, x % y);
}

ll get_rand(ll x)
{
	return (gen() % x + x) % x;
}

template <typename T>
void sort(vector<T>& x)
{
	sort(x.begin(), x.end());
}

template <typename T>
void reverse(vector<T>& x)
{
	reverse(x.begin(), x.end());
}

bool check(int x)
{
	vector<int>a(10, 0);

	while (x > 0)
	{
		int now = x % 10;
		a[now]++;
		if (a[now] > 1)
			return false;
		x /= 10;
	}
	return true;
}

ll bin_pow(ll x, ll pow)
{
	if (pow == 0)
		return 1;
	if (pow & 1)
	{
		return (bin_pow(x, pow - 1) * x) % mod;
	}
	else
	{
		ll tmp = bin_pow(x, pow / 2);
		return (tmp * tmp) % mod;
	}
}

vector<ll>get_primes(ll x)
{
	vector<ll>answer;
	for (ll i = 2; i * i <= x; i++)
	{
		if (x % i == 0)
		{
			answer.push_back(i);
			while (x % i == 0)
				x /= i;
		}
	}
	if (x != 1)
		answer.push_back(x);
	return answer;
}

int max_x, max_y, n;

vector<int>a;

void nullify(int&x, pair<int, int>&a)
{
	if (a.first == x || a.second == x)
	{
		x = -1;
	}
}

void insert_to_pair(int x, pair<int, int>&ax)
{
	if (x == -1)
		return;
	if (ax.first == -1 || a[ax.first] < a[x])
	{
		ax.second = ax.first;
		ax.first = x;
		return;
	}
	if (ax.second == -1 || a[ax.second] < a[x])
	{
		ax.second = x;
	}
}

void merge_pairs(pair<int, int>& f, pair<int, int>s)
{
	nullify(s.first, f);
	nullify(s.second, f);

	insert_to_pair(s.first, f);
	insert_to_pair(s.second, f);
}

void solve()
{
	int n;
	cin >> n;
	a.resize(n);
	vector<pair<int, int>>fact_t(MAX_N, { -1, -1 });
	vector<int>reverse_t(MAX_N, -1);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		merge_pairs(fact_t[a[i]], { i, -1 });
	}

	for (int i = MAX_N - 1; i > 0; i--)
	{
		for (int j = 0; j < MAX_POW; j++)
		{
			if (i & (1 << j))
			{
				auto new_bm = i - (1 << j);
				merge_pairs(fact_t[new_bm], fact_t[i]);
			}
		}
	}

	for (int i = 0; i < MAX_N; i++)
	{
		if (fact_t[i].second != -1)
		{
			reverse_t[i] = i;
		}
		else
		{
			for (int j = 0; j < MAX_POW; j++)
			{
				if (i & (1 << j))
				{
					auto new_bm = i - (1 << j);
					reverse_t[i] = max(reverse_t[i], reverse_t[new_bm]);
				}
			}
		}
	}

	auto answer = 0;

	for (int i = 0; i < n - 2; i++)
	{
		auto new_bm = MAX_N - 1 - a[i];
		answer = max(answer, a[i] | reverse_t[new_bm]);
	}
	cout << answer << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand(58164);

	solve();

	return 0;
}


//#pragma GCC optimize("Ofast")
using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <map>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <math.h>
#include <chrono>
#include <cctype>
#include <random>

#ifdef _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

#ifdef _DEBUG
const int MAX_POW = 4;
#else
const int MAX_POW = 21;
#endif

const int MAX_N = 1 << MAX_POW;

typedef long long ll;
using pll = pair<ll, ll>;

const double delta = 1e-8;
const long long mod = 1e9 + 7;
const int magic_const = 1e9;
const ll INF = 3e18;
const ll BIG_DT = 1e12;

mt19937 gen(54323244234);

ll modoper(ll x)
{
	return ((x % mod) + mod) % mod;
}

ll gcd(ll x, ll y)
{
	return y == 0 ? x : gcd(y, x % y);
}

ll get_rand(ll x)
{
	return (gen() % x + x) % x;
}

template <typename T>
void sort(vector<T>& x)
{
	sort(x.begin(), x.end());
}

template <typename T>
void reverse(vector<T>& x)
{
	reverse(x.begin(), x.end());
}

bool check(int x)
{
	vector<int>a(10, 0);

	while (x > 0)
	{
		int now = x % 10;
		a[now]++;
		if (a[now] > 1)
			return false;
		x /= 10;
	}
	return true;
}

ll bin_pow(ll x, ll pow)
{
	if (pow == 0)
		return 1;
	if (pow & 1)
	{
		return (bin_pow(x, pow - 1) * x) % mod;
	}
	else
	{
		ll tmp = bin_pow(x, pow / 2);
		return (tmp * tmp) % mod;
	}
}

vector<ll>get_primes(ll x)
{
	vector<ll>answer;
	for (ll i = 2; i * i <= x; i++)
	{
		if (x % i == 0)
		{
			answer.push_back(i);
			while (x % i == 0)
				x /= i;
		}
	}
	if (x != 1)
		answer.push_back(x);
	return answer;
}

int max_x, max_y, n;

vector<int>a;

void nullify(int&x, pair<int, int>&a)
{
	if (a.first == x || a.second == x)
	{
		x = -1;
	}
}

void insert_to_pair(int x, pair<int, int>&ax)
{
	if (x == -1)
		return;
	if (ax.first == -1 || a[ax.first] < a[x])
	{
		ax.second = ax.first;
		ax.first = x;
		return;
	}
	if (ax.second == -1 || a[ax.second] < a[x])
	{
		ax.second = x;
	}
}

void merge_pairs(pair<int, int>& f, pair<int, int>s)
{
	nullify(s.first, f);
	nullify(s.second, f);

	insert_to_pair(s.first, f);
	insert_to_pair(s.second, f);
}

void solve()
{
	int n;
	cin >> n;
	a.resize(n);
	vector<pair<int, int>>fact_t(MAX_N, { -1, -1 });
	vector<int>reverse_t(MAX_N, -1);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		merge_pairs(fact_t[a[i]], { i, -1 });
	}

	for (int i = MAX_N - 1; i > 0; i--)
	{
		for (int j = 0; j < MAX_POW; j++)
		{
			if (i & (1 << j))
			{
				auto new_bm = i - (1 << j);
				merge_pairs(fact_t[new_bm], fact_t[i]);
			}
		}
	}

	for (int i = 0; i < MAX_N; i++)
	{
		if (fact_t[i].second != -1)
		{
			reverse_t[i] = i;
		}
		else
		{
			for (int j = 0; j < MAX_POW; j++)
			{
				if (i & (1 << j))
				{
					auto new_bm = i - (1 << j);
					reverse_t[i] = max(reverse_t[i], reverse_t[new_bm]);
				}
			}
		}
	}

	auto answer = 0;

	for (int i = 0; i < n - 2; i++)
	{
		auto new_bm = MAX_N - 1 - a[i];
		answer = max(answer, i | reverse_t[new_bm]);
	}
	cout << answer << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand(58164);

	solve();

	return 0;
}


//#pragma GCC optimize("Ofast")
using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <map>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <math.h>
#include <chrono>
#include <cctype>
#include <random>

#ifdef _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

#ifdef _DEBUG
const int MAX_POW = 4;
#else
const int MAX_POW = 21;
#endif

const int MAX_N = 1 << MAX_POW;

typedef long long ll;
using pll = pair<ll, ll>;

const double delta = 1e-8;
const long long mod = 1e9 + 7;
const int magic_const = 1e9;
const ll INF = 3e18;
const ll BIG_DT = 1e12;

mt19937 gen(54323244234);

ll modoper(ll x)
{
	return ((x % mod) + mod) % mod;
}

ll gcd(ll x, ll y)
{
	return y == 0 ? x : gcd(y, x % y);
}

ll get_rand(ll x)
{
	return (gen() % x + x) % x;
}

template <typename T>
void sort(vector<T>& x)
{
	sort(x.begin(), x.end());
}

template <typename T>
void reverse(vector<T>& x)
{
	reverse(x.begin(), x.end());
}

bool check(int x)
{
	vector<int>a(10, 0);

	while (x > 0)
	{
		int now = x % 10;
		a[now]++;
		if (a[now] > 1)
			return false;
		x /= 10;
	}
	return true;
}

ll bin_pow(ll x, ll pow)
{
	if (pow == 0)
		return 1;
	if (pow & 1)
	{
		return (bin_pow(x, pow - 1) * x) % mod;
	}
	else
	{
		ll tmp = bin_pow(x, pow / 2);
		return (tmp * tmp) % mod;
	}
}

vector<ll>get_primes(ll x)
{
	vector<ll>answer;
	for (ll i = 2; i * i <= x; i++)
	{
		if (x % i == 0)
		{
			answer.push_back(i);
			while (x % i == 0)
				x /= i;
		}
	}
	if (x != 1)
		answer.push_back(x);
	return answer;
}

int max_x, max_y, n;

vector<int>a;

void nullify(int&x, pair<int, int>&a)
{
	if (a.first == x || a.second == x)
	{
		x = -1;
	}
}

void insert_to_pair(int x, pair<int, int>&ax)
{
	if (x == -1)
		return;
	if (ax.first == -1 || a[ax.first] < a[x])
	{
		ax.second = ax.first;
		ax.first = x;
		return;
	}
	if (ax.second == -1 || a[ax.second] < a[x])
	{
		ax.second = x;
	}
}

void merge_pairs(pair<int, int>& f, pair<int, int>s)
{
	nullify(s.first, f);
	nullify(s.second, f);

	insert_to_pair(s.first, f);
	insert_to_pair(s.second, f);
}

void solve()
{
	int n;
	cin >> n;
	a.resize(n);
	vector<pair<int, int>>fact_t(MAX_N, { -1, -1 });
	vector<int>reverse_t(MAX_N, -1);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		merge_pairs(fact_t[a[i]], { i, -1 });
	}

	for (int i = MAX_N - 1; i > 0; i--)
	{
		for (int j = 0; j < MAX_POW; j++)
		{
			if (i & (1 << j))
			{
				auto new_bm = i - (1 << j);
				merge_pairs(fact_t[new_bm], fact_t[i]);
			}
		}
	}

	for (int i = 0; i < MAX_N; i++)
	{
		if (fact_t[i].second != -1)
		{
			reverse_t[i] = i;
		}
		else
		{
			for (int j = 0; j < MAX_POW; j++)
			{
				if (i & (1 << j))
				{
					auto new_bm = i - (1 << j);
					reverse_t[i] = max(reverse_t[i], reverse_t[new_bm]);
				}
			}
		}
	}

	auto answer = 0;

	for (auto i : a)
	{
		auto new_bm = MAX_N - 1 - i;
		answer = max(answer, i | reverse_t[new_bm]);
	}
	cout << answer << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand(58164);

	solve();

	return 0;
}


#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <queue>
#include <bitset>
#include <string>

#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;

const int N = 3000010;
const int M = 22;

int n;
int a[N];
pair <int, int> dp[1 << M];

void upd(pair <int, int> &p, int val) {
    if (val > p.first) {
        p.second = p.first;
        p.first = val;
    }
    else if (val > p.second) {
        p.second = val;
    }
}

void update(pair <int, int> &p, pair<int, int> q) {
    upd(p, q.first);
    upd(p, q.second);
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < (1 << M); i++) dp[i] = mp(-1, -1);
    for (int i = 1; i <= n; i++) update(dp[a[i]], mp(i, -1));
    for (int mask = (1 << M) - 1; mask >= 0; mask--) {
        for (int i = 0; i < M; i++) {
            if (!(mask & (1 << i))) update(dp[mask], dp[mask ^ (1 << i)]);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int mask = a[i];
        int maskcur = 0;
        int res = 0;
        for (int j = M - 1; j >= 0; j--) {
            if (mask & (1 << j)) {
                res |= (1 << j);
                continue;
            }
            if (dp[maskcur ^ (1 << j)].second > i) {
                maskcur |= (1 << j);
                res |= (1 << j);
            }
        }
        ans = max(ans, res);
    }
    cout << ans;
	return 0;
}


#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <queue>
#include <bitset>
#include <string>

#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;

const int N = 3000010;
const int M = 22;

int n;
int a[N];
pair <int, int> dp[1 << M];

void upd(pair <int, int> &p, int val) {
    if (val > p.first) {
        p.second = p.first;
        p.first = val;
    }
    else if (val > p.second) {
        p.second = val;
    }
}

void update(pair <int, int> &p, pair<int, int> q) {
    upd(p, q.first);
    upd(p, q.second);
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < (1 << M); i++) dp[i] = mp(-1, -1);
    for (int i = 1; i <= n; i++) update(dp[a[i]], mp(i, -1));
    for (int mask = (1 << M) - 1; mask >= 0; mask--) {
        for (int i = 0; i < M; i++) {
            if (!(mask & (1 << i))) update(dp[mask], dp[mask ^ (1 << i)]);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n - 2; i++) {
        int mask = a[i];
        int maskcur = 0;
        int res = 0;
        for (int j = M - 1; j >= 0; j--) {
            if (mask & (1 << j)) {
                res |= (1 << j);
                continue;
            }
            if (dp[maskcur ^ (1 << j)].second > i) {
                maskcur |= (1 << j);
                res |= (1 << j);
            }
        }
        ans = max(ans, res);
    }
    cout << ans;
	return 0;
}


#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <queue>
#include <bitset>
#include <string>

#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;

const int N = 3000010;
const int M = 20;

int n;
int a[N];
pair <int, int> dp[1 << M];

void upd(pair <int, int> &p, int val) {
    if (val > p.first) {
        p.second = p.first;
        p.first = val;
    }
    else if (val > p.second) {
        p.second = val;
    }
}

void update(pair <int, int> &p, pair<int, int> q) {
    upd(p, q.first);
    upd(p, q.second);
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < (1 << M); i++) dp[i] = mp(-1, -1);
    for (int i = 1; i <= n; i++) update(dp[a[i]], mp(i, -1));
    for (int mask = (1 << M) - 1; mask >= 0; mask--) {
        for (int i = 0; i < M; i++) {
            if (!(mask & (1 << i))) update(dp[mask], dp[mask ^ (1 << i)]);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int mask = a[i];
        int maskcur = 0;
        int res = 0;
        for (int j = M - 1; j >= 0; j--) {
            if (mask & (1 << j)) {
                res |= (1 << j);
                continue;
            }
            if (dp[maskcur ^ (1 << j)].second > i) {
                maskcur |= (1 << j);
                res |= (1 << j);
            }
        }
        ans = max(ans, res);
    }
    cout << ans;
	return 0;
}


#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <queue>
#include <bitset>
#include <string>

#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;

const int N = 3000010;
const int M = 22;

int n;
int a[N];
pair <int, int> dp[1 << M];

void upd(pair <int, int> &p, int val) {
    if (val > p.first) {
        p.second = p.first;
        p.first = val;
    }
    else if (val < p.first && val > p.second) {
        p.second = val;
    }
}

void update(pair <int, int> &p, pair<int, int> q) {
    upd(p, q.first);
    upd(p, q.second);
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < (1 << M); i++) dp[i] = mp(-1, -1);
    for (int i = 1; i <= n; i++) update(dp[a[i]], mp(i, -1));
    for (int mask = (1 << M) - 1; mask >= 0; mask--) {
        for (int i = 0; i < M; i++) {
            if (!(mask & (1 << i))) update(dp[mask], dp[mask ^ (1 << i)]);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n - 2; i++) {
        int mask = a[i];
        int maskcur = 0;
        int res = 0;
        for (int j = M - 1; j >= 0; j--) {
            if (mask & (1 << j)) {
                res |= (1 << j);
                continue;
            }
            if (dp[maskcur ^ (1 << j)].second > i) {
                maskcur |= (1 << j);
                res |= (1 << j);
            }
        }
        ans = max(ans, res);
    }
    cout << ans;
	return 0;
}


#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cmath>
#include<string>
#include<cstring>
#include<iostream>
#include<iomanip>
// #define SGN(n) (n>0? 1 :-1)

using namespace std;
typedef long long ll;
#define mod 998244353

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<pair<int,int>> dp(1<<21, {INT_MIN,INT_MIN});
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[a[i]].second = dp[a[i]].first;
        dp[a[i]].first = i;
    }
    int res = 0;
    for(int i=0;i<21;i++){
        for(int mask = 0; mask < 1<<21; mask++){
            if((mask & (1<<i)) == 0){
                auto tmp = dp[mask | (1<<i)];
                if(dp[mask].first < tmp.first){
                    swap(dp[mask].first, tmp.first);
                    dp[mask].second = max(tmp.first, tmp.second);
                }
                else{
                    dp[mask].second = max(dp[mask].second , tmp.first);
                }
            }
        }
    }
    // cout<<dp[0].first<<' '<<dp[0].second<<endl;
    int tmask = (1<<21)-1;
    for(int i=0;i<n;i++){
        int comp = tmask ^ a[i];
        int real=0;
        for(int j=20;j>=0;j--){
            if(comp&(1<<j)){
                if(dp[real+(1<<j)].second>i){
                    real += 1<<j;
                }
            }
        }
        if(dp[real].second>i){
            // cout<< a[i]<<' '<<real<<' '<<dp[real].first<<' '<<dp[real].second<<endl;
            res = max(res, a[i] | real);
        }
    }
    cout<<res<<endl;
    return 0;
}


#include <stdio.h>
#include <string.h>

#define N	1000000
#define H	21	/* H = ceil(log2(2000000)) */
#define A	(1 << H)

int main() {
	static int aa[N], jj[A], kk[A];
	int n, h, i, a;

	scanf("%d", &n);
	memset(jj, -1, sizeof jj);
	memset(kk, -1, sizeof kk);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		aa[i] = a;
		jj[a] = kk[a], kk[a] = i;
	}
	for (h = 0; h < H; h++)
		for (a = 0; a < 1 << H; a++)
			if ((a & 1 << h) == 0) {
				int b = a ^ 1 << h;

				i = jj[b];
				if (kk[a] < i)
					jj[a] = kk[a], kk[a] = i;
				else if (jj[a] < i)
					jj[a] = i;
				i = kk[b];
				if (kk[a] < i)
					jj[a] = kk[a], kk[a] = i;
				else if (jj[a] < i)
					jj[a] = i;
			}
	for (h = H - 1, a = 0; h >= 0; h--) {
		int ok;

		a ^= 1 << h;
		ok = 0;
		for (i = 0; i < n; i++)
			if (i < jj[a & ~aa[i]]) {
				ok = 1;
				break;
			}
		if (!ok)
			a ^= 1 << h;
	}
	printf("%d\n", a);
	return 0;
}


//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::cmp::max;

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let m = 4;
    let mut dp = vec![(0, 0); 1 << m];
    for (i, &a) in a.iter().enumerate() {
        dp[a] = (i + 1, dp[a].0);
    }
    for j in 0..m {
        for i in 0..(1 << m) {
            if (i >> j) & 1 == 1 {
                let (a, b) = dp[i];
                let (c, d) = dp[i ^ (1 << j)];
                dp[i ^ (1 << j)] = if a >= c {
                    (a, max(b, c))
                } else {
                    (c, max(a, d))
                };
            }
        }
    }
    let mut ans = 0;
    for (i, &a) in a.iter().enumerate().rev().skip(2).rev() {
        let mut bit = 0;
        for j in (0..m).rev() {
            if (a >> j) & 1 == 1 {
                continue;
            }
            if dp[bit | (1 << j)].1 > i + 1 {
                bit |= 1 << j;
            }
        }
        ans = max(ans, a | bit);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::cmp::max;

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let m = 21;
    let mut dp = vec![(0, 0); 1 << m];
    for (i, &a) in a.iter().enumerate() {
        dp[a] = (i + 1, dp[a].0);
    }
    for j in 0..m {
        for i in 0..(1 << m) {
            if (i >> j) & 1 == 1 {
                let (a, b) = dp[i];
                let (c, d) = dp[i ^ (1 << j)];
                dp[i ^ (1 << j)] = if a >= c {
                    (a, max(b, c))
                } else {
                    (c, max(a, d))
                };
            }
        }
    }
    let mut ans = 0;
    for (i, &a) in a.iter().enumerate() {
        let mut bit = 0;
        for j in (0..m).rev() {
            if (a >> j) & 1 == 1 {
                continue;
            }
            if dp[bit | (1 << j)].1 > i + 1 {
                bit |= 1 << j;
            }
        }
        ans = max(ans, a | bit);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let b = 21;
    let mut dp = vec![(0, 0); 1 << b];
    for i in (0..n).rev() {
        let (x, _) = dp[a[i]];
        dp[a[i]] = (i, x);
    }
    for i in (0..(1 << b)).rev() {
        let (x, y) = dp[i];
        let mut bit = i;
        while bit > 0 {
            let k = bit.trailing_zeros() as usize;
            let (z, w) = dp[i ^ (1 << k)];
            dp[i ^ (1 << k)] = if x > z {
                (x, if x != z && z > y {z} else {y})
            } else {
                (z, if x != z && x > w {x} else {w})
            };
            bit ^= 1 << k;
        }
    }
    let mut ans = 0;
    for i in 0..n {
        let mut bit = 0;
        for j in (0..b).rev() {
            if (a[i] >> j) & 1 == 1 {
                continue;
            }
            if dp[bit | (1 << j)].1 > i {
                bit |= 1 << j;
            }
        }
        ans = std::cmp::max(ans, a[i] | bit);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::cmp::max;

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let m = 21;
    let mut dp = vec![(0, 0); 1 << m];
    for (i, &a) in a.iter().enumerate() {
        dp[a] = (i + 1, dp[a].0);
    }
    for j in 0..m {
        for i in 0..(1 << m) {
            if (i >> j) & 1 == 1 {
                let (a, b) = dp[i];
                let (c, d) = dp[i ^ (1 << j)];
                dp[i ^ (1 << j)] = if a >= c {
                    (a, max(b, c))
                } else {
                    (c, max(a, d))
                };
            }
        }
    }
    let mut ans = 0;
    for (i, &a) in a.iter().enumerate().rev().skip(2).rev() {
        let mut bit = 0;
        for j in (0..m).rev() {
            if (a >> j) & 1 == 1 {
                continue;
            }
            if dp[bit | (1 << j)].1 > i + 1 {
                bit |= 1 << j;
            }
        }
        ans = max(ans, a | bit);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let b = 21;
    let mut dp = vec![(0, 0); 1 << b];
    for i in 0..n {
        let (x, _) = dp[a[i]];
        dp[a[i]] = (i, x);
    }
    for i in (0..(1 << b)).rev() {
        let (x, y) = dp[i];
        let mut bit = i;
        while bit > 0 {
            let k = bit.trailing_zeros() as usize;
            let (z, w) = dp[i ^ (1 << k)];
            dp[i ^ (1 << k)] = if x > z {
                if x != z && z > y {
                    (x, z)
                } else if y > w {
                    (x, y)
                } else {
                    (x, w)
                }
            } else {
                if x != z && x > w {
                    (z, x)
                } else if y > w {
                    (z, y)
                } else {
                    (z, w)
                }
            };
            bit ^= 1 << k;
        }
    }
    let mut ans = 0;
    for i in 0..(n - 2) {
        let mut bit = 0;
        for j in (0..b).rev() {
            if (a[i] >> j) & 1 == 1 {
                continue;
            }
            if dp[bit | (1 << j)].1 > i {
                bit |= 1 << j;
            }
        }
        ans = std::cmp::max(ans, a[i] | bit);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


use std::io::Write;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            std::io::stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

const BITS: u8 = 21;
const INF: i32 = 1000000000;

type Better = fn (old: i32, new: i32) -> bool;

fn update(ptr: &mut (i32, i32), value: i32, cmp: Better) {
    if cmp(value, ptr.0) {
        ptr.1 = ptr.0;
        ptr.0 = value;
    } else if value != ptr.0 && cmp(value, ptr.1) {
        ptr.1 = value;
    }
}

fn update_all(dp:&mut Vec<(i32, i32)>, cmp: Better) {
    for i in 1..(1<<BITS) {
        let mask = (1<<BITS)-i;
        for bit in 0..BITS {
            if ((mask >> bit) & 1) == 1 {
                let submask = mask ^ (1 << bit);
                let value0 = dp[mask].0;
                let value1 = dp[mask].1;
                update(&mut dp[submask], value0, cmp);
                update(&mut dp[submask], value1, cmp);
            }
        }
    }
}
fn less(x: i32, y: i32) -> bool { x < y }
fn greater(x: i32, y: i32) -> bool { x > y }

fn main() {
    let stdout = std::io::stdout();
    let mut out = std::io::BufWriter::new(stdout.lock());
    let mut scan = Scanner::default();

    let n: usize = scan.next();
    let mut a: Vec<u32> = vec![0; n];
    for i in 0..n {
        a[i] = scan.next();
    }

    let mut min_prefix: Vec<(i32, i32)> = vec![(INF, INF); 1 << BITS];
    for i in 0..n {
        update(&mut min_prefix[a[i] as usize], i as i32, less);
    }
    update_all(&mut min_prefix, less);

    let mut max_suffix: Vec<(i32, i32)> = vec![(-1, -1); 1 << BITS];
    for i in 0..n {
        update(&mut max_suffix[a[i] as usize], i as i32, greater);
    }
    update_all(&mut max_suffix, greater);

    let mut ans: i32 = 0;
    for bit in 0..BITS {
        let candidate = ans | (1 << (BITS-1-bit));
        let mut is_good = false;
        let mut lhs = candidate;
        loop {
            let rhs = candidate ^ lhs;

            if min_prefix[lhs as usize].0 < max_suffix[rhs as usize].1 &&
               max_suffix[rhs as usize].1 < max_suffix[rhs as usize].0
            {
                is_good = true;
                break;
            }

            if lhs == 0 {
                break;
            }
            lhs = candidate & (lhs - 1);
        }
        if is_good {
            ans = candidate;
        }
    }
    writeln!(out, "{}", ans).unwrap();
}


import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.List;
 import java.util.*;
public  class realfast implements Runnable
  {
    private static final int INF = (int) 1e9;
    long in= 998244353;
    long fac[]= new long[3000];
    public  void solve() throws IOException
    {

      int n = readInt();
      int arr[]=new int[n];
      for(int i =0;i<n;i++)
        arr[i]= readInt();

      int dp[]=new int[1<<21];

      dp(dp,arr[n-1],0);
      dp(dp,arr[n-2],0);
      int max =0;
      for(int i =n-3;i>=0;i--)
      {
        int gal=0;
        for(int j =20;j>=0;j--)
        {
            int cal = 1<<j;
            if((cal&arr[i])==0)
            {
                 if(dp[gal+cal]>=2)
                {
                    gal=gal+cal;
                }
            }

            max=Math.max(max,gal+arr[i]);
        }
        dp(dp,arr[i],0);
      }

      out.println(max);

    }

    public void dp(int dp[], int val, int i )
    {
        if(dp[val]>=2)
            return ;
          dp[val]++;
        for(int j =i;j<=20;j++)
        {
            int cal = 1<<j;
            if((cal&val)!=0)
            {
                  dp(dp,val-cal,j+1);
            }
        }

    }

    public int value (int seg[], int left , int right ,int index, int l, int r)
    {

            if(left>right)
            {
              return -100000000;
            }
            if(right<l||left>r)
                return -100000000;
            if(left>=l&&right<=r)
                return seg[index];
            int mid = left+(right-left)/2;
            int val = value(seg,left,mid,2*index+1,l,r);
            int val2 = value(seg,mid+1,right,2*index+2,l,r);
            return Math.max(val,val2);

    }

    public int gcd(int a , int b )
    {
      if(a<b)
      {
        int t =a;
        a=b;
        b=t;
      }
      if(a%b==0)
        return b ;
      return gcd(b,a%b);
    }
    public long pow(long n , long p,long m)
    {
         if(p==0)
            return 1;
        long val = pow(n,p/2,m);;
        val= (val*val)%m;
        if(p%2==0)
            return val;
        else
            return (val*n)%m;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args) {
        new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
    }

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    private PrintWriter out;

    @Override
    public void run() {
        try {
            if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            solve();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // nothing
            }
            out.close();
        }
    }

    private String readString() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}
class edge implements Comparable<edge>{
    int val ;
    int color;

    edge(int u, int v)
    {
       this.val=u;
       this.color=v;
    }
    public int compareTo(edge e)
    {
        return this.val-e.val;
    }
}


import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.List;
 import java.util.*;
 public class realfast implements Runnable
  {
    private static final int INF = (int) 1e9;
    long in= 998244353;
    long fac[]= new long[3000];
    public  void solve() throws IOException
    {

      int n = readInt();
      int arr[]=new int[n];
      for(int i =0;i<n;i++)
        arr[i]= readInt();

      int dp[]=new int[1<<22];

      dp(dp,arr[n-1]);
      dp(dp,arr[n-2]);
      int max =0;
      for(int i =n-3;i>=0;i--)
      {
        int gal=0;
        for(int j =21;j>=0;j--)
        {
            int cal = 1<<j;
            if((cal&arr[i])==0)
            {
                 if(dp[gal+cal]>=2)
                {
                    gal=gal+cal;
                }
            }

            max=Math.max(max,gal+arr[i]);
        }
        dp(dp,arr[i]);
      }

      out.println(max);

    }

    public void dp(int dp[], int val)
    {
        if(dp[val]>=2)
            return ;
          dp[val]++;
        for(int j =0;j<=21;j++)
        {
            int cal = 1<<j;
            if((cal&val)!=0)
            {
                  dp(dp,val-cal);
            }
        }

    }

    public int value (int seg[], int left , int right ,int index, int l, int r)
    {

            if(left>right)
            {
              return -100000000;
            }
            if(right<l||left>r)
                return -100000000;
            if(left>=l&&right<=r)
                return seg[index];
            int mid = left+(right-left)/2;
            int val = value(seg,left,mid,2*index+1,l,r);
            int val2 = value(seg,mid+1,right,2*index+2,l,r);
            return Math.max(val,val2);

    }

    public int gcd(int a , int b )
    {
      if(a<b)
      {
        int t =a;
        a=b;
        b=t;
      }
      if(a%b==0)
        return b ;
      return gcd(b,a%b);
    }
    public long pow(long n , long p,long m)
    {
         if(p==0)
            return 1;
        long val = pow(n,p/2,m);;
        val= (val*val)%m;
        if(p%2==0)
            return val;
        else
            return (val*n)%m;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args) {
        new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
    }

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    private PrintWriter out;

    @Override
    public void run() {
        try {
            if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            solve();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // nothing
            }
            out.close();
        }
    }

    private String readString() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}
class edge implements Comparable<edge>{
    int val ;
    int color;

    edge(int u, int v)
    {
       this.val=u;
       this.color=v;
    }
    public int compareTo(edge e)
    {
        return this.val-e.val;
    }
}


import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.List;
 import java.util.*;
public  class realfast implements Runnable
  {
    private static final int INF = (int) 1e9;
    long in= 998244353;
    long fac[]= new long[3000];
    public  void solve() throws IOException
    {

      int n = readInt();
      int arr[]=new int[n];
      for(int i =0;i<n;i++)
        arr[i]= readInt();

      int dp[]=new int[1<<21];

      dp(dp,arr[n-1]);
      dp(dp,arr[n-2]);
      int max =0;
      for(int i =n-3;i>=0;i--)
      {
        int gal=0;
        for(int j =20;j>=0;j--)
        {
            int cal = 1<<j;
            if((cal&arr[i])==0)
            {
                 if(dp[gal+cal]>=2)
                {
                    gal=gal+cal;
                }
            }

            max=Math.max(max,gal+arr[i]);
        }
        dp(dp,arr[i]);
      }

      out.println(max);

    }

    public void dp(int dp[], int val)
    {
        if(dp[val]>=2)
            return ;
          dp[val]++;
        for(int j =0;j<=20;j++)
        {
            int cal = 1<<j;
            if((cal&val)!=0)
            {
                  dp(dp,val-cal);
            }
        }

    }

    public int value (int seg[], int left , int right ,int index, int l, int r)
    {

            if(left>right)
            {
              return -100000000;
            }
            if(right<l||left>r)
                return -100000000;
            if(left>=l&&right<=r)
                return seg[index];
            int mid = left+(right-left)/2;
            int val = value(seg,left,mid,2*index+1,l,r);
            int val2 = value(seg,mid+1,right,2*index+2,l,r);
            return Math.max(val,val2);

    }

    public int gcd(int a , int b )
    {
      if(a<b)
      {
        int t =a;
        a=b;
        b=t;
      }
      if(a%b==0)
        return b ;
      return gcd(b,a%b);
    }
    public long pow(long n , long p,long m)
    {
         if(p==0)
            return 1;
        long val = pow(n,p/2,m);;
        val= (val*val)%m;
        if(p%2==0)
            return val;
        else
            return (val*n)%m;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args) {
        new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
    }

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    private PrintWriter out;

    @Override
    public void run() {
        try {
            if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            solve();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // nothing
            }
            out.close();
        }
    }

    private String readString() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}
class edge implements Comparable<edge>{
    int val ;
    int color;

    edge(int u, int v)
    {
       this.val=u;
       this.color=v;
    }
    public int compareTo(edge e)
    {
        return this.val-e.val;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.PrintWriter;

public class F1208 {
	static class Scanner {
		BufferedReader br;
		StringTokenizer tk = new StringTokenizer("");

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		public int nextInt() throws IOException {
			if (tk.hasMoreTokens())
				return Integer.parseInt(tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return nextInt();
		}

		public long nextLong() throws IOException {
			if (tk.hasMoreTokens())
				return Long.parseLong(tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return nextLong();
		}

		public String next() throws IOException {
			if (tk.hasMoreTokens())
				return (tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return next();
		}

		public String nextLine() throws IOException {
			tk = new StringTokenizer("");
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			if (tk.hasMoreTokens())
				return Double.parseDouble(tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return nextDouble();
		}

		public char nextChar() throws IOException {
			if (tk.hasMoreTokens())
				return (tk.nextToken().charAt(0));
			tk = new StringTokenizer(br.readLine());
			return nextChar();
		}

		public int[] nextIntArray(int n) throws IOException {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) throws IOException {
			long a[] = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public int[] nextIntArrayOneBased(int n) throws IOException {
			int a[] = new int[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArrayOneBased(int n) throws IOException {
			long a[] = new long[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextLong();
			return a;
		}

	}

	public static void main(String args[]) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					solve();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();

	}
	static class Pair{
		int f,s;
		Pair(){
			f=s=-1;
		}
		void add(int x){
			if(x>=f){
				s=f;
				f=x;
			}else if(x>s)
				s=x;
		}
		void add(Pair x){
			add(x.s);
			add(x.f);
		}
	}
	static void solve() throws IOException {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n=in.nextInt();
		Pair p[]=new Pair[1<<21];
		for(int i=0;i<1<<21;i++)
			p[i]=new Pair();
		int a[]=in.nextIntArray(n);
		for(int i=0;i<n;i++)
			p[a[i]].add(i);
		for(int i=0;i<21;i++){
			for(int mask=(1<<21)-1;mask>=0;mask--){
				if((mask&(1<<i))!=0)
					p[mask^(1<<i)].add(p[mask]);
			}
		}
		int ans=a[0];
		for(int i=0;i<n;i++){
			int w=0;
			for(int j=20;j>=0;j--){
				if((a[i]&1<<j)==0 && p[w|(1<<j)].s>i)
					w|=(1<<j);
			}
			if(p[w].s>i)
				ans=Math.max(ans,a[i]|w);
		}
		System.out.println(ans);
		out.close();

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.PrintWriter;

public class F1208 {
	static class Scanner {
		BufferedReader br;
		StringTokenizer tk = new StringTokenizer("");

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		public int nextInt() throws IOException {
			if (tk.hasMoreTokens())
				return Integer.parseInt(tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return nextInt();
		}

		public long nextLong() throws IOException {
			if (tk.hasMoreTokens())
				return Long.parseLong(tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return nextLong();
		}

		public String next() throws IOException {
			if (tk.hasMoreTokens())
				return (tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return next();
		}

		public String nextLine() throws IOException {
			tk = new StringTokenizer("");
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			if (tk.hasMoreTokens())
				return Double.parseDouble(tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return nextDouble();
		}

		public char nextChar() throws IOException {
			if (tk.hasMoreTokens())
				return (tk.nextToken().charAt(0));
			tk = new StringTokenizer(br.readLine());
			return nextChar();
		}

		public int[] nextIntArray(int n) throws IOException {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) throws IOException {
			long a[] = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public int[] nextIntArrayOneBased(int n) throws IOException {
			int a[] = new int[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArrayOneBased(int n) throws IOException {
			long a[] = new long[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextLong();
			return a;
		}

	}

	public static void main(String args[]) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					solve();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();

	}
	static class Pair{
		int f,s;
		Pair(){
			f=s=-1;
		}
		void add(int x){
			if(x>=f){
				s=f;
				f=x;
			}else if(x>s)
				s=x;
		}
		void add(Pair x){
			add(x.s);
			add(x.f);
		}
	}
	static void solve() throws IOException {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n=in.nextInt();
		Pair p[]=new Pair[1<<21];
		for(int i=0;i<1<<21;i++)
			p[i]=new Pair();
		int a[]=in.nextIntArray(n);
		for(int i=0;i<n;i++)
			p[a[i]].add(i);
		for(int i=0;i<21;i++){
			for(int mask=(1<<21)-1;mask>=0;mask--){
				if((mask&(1<<i))!=0)
					p[mask^(1<<i)].add(p[mask]);
			}
		}
		int ans=a[0];
		for(int i=0;i<n;i++){
			int w=0;
			for(int j=20;j>=0;j--){
				if((a[i]&1<<j)==0 && p[w|(1<<j)].s>i)
					w|=(1<<j);
			}
			ans=Math.max(ans,a[i]|w);
		}
		System.out.println(ans);
		out.close();

	}
}


import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.Arrays;

public class CF1208F {
    public static void main(String[] args) throws Exception {
        boolean local = System.getProperty("ONLINE_JUDGE") == null;
        boolean async = false;

        Charset charset = Charset.forName("ascii");

        FastIO io = local ? new FastIO(new FileInputStream("D:\\DATABASE\\TESTCASE\\Code.in"), System.out, charset) : new FastIO(System.in, System.out, charset);
        Task task = new Task(io, new Debug(local));

        if (async) {
            Thread t = new Thread(null, task, "dalt", 1 << 27);
            t.setPriority(Thread.MAX_PRIORITY);
            t.start();
            t.join();
        } else {
            task.run();
        }

        if (local) {
            io.cache.append("\n\n--memory -- \n" + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20) + "M");
        }

        io.flush();
    }

    public static class Task implements Runnable {
        final FastIO io;
        final Debug debug;
        int inf = (int) 1e8;
        BitOperator bo = new BitOperator();

        public Task(FastIO io, Debug debug) {
            this.io = io;
            this.debug = debug;
        }

        @Override
        public void run() {
            solve();
        }

        public void solve() {
            int n = io.readInt();
            int[] data = new int[n];
            int limit = 2000000;
            Container[] containers = new Container[limit + 1];
            for (int i = 0; i <= limit; i++) {
                containers[i] = new Container();
            }
            for (int i = 0; i < n; i++) {
                data[i] = io.readInt();
                containers[data[i]].populate(i);
            }
            for (int i = limit; i >= 0; i--) {
                for (int j = 0; j <= 21; j++) {
                    int k = bo.setBit(i, j, true);
                    if (k == i || k > limit) {
                        continue;
                    }
                    containers[i].populate(containers[k].a);
                    containers[i].populate(containers[k].b);
                }
            }

            int max = 0;
            for (int i = 0; i < n - 2; i++) {
                int bits = 0;
                for (int j = 21; j >= 0; j--) {
                    if (bo.bitAt(data[i], j) == 1) {
                        continue;
                    }
                    int test = bo.setBit(bits, j, true);
                    if (test <= limit && containers[test].getMin() > i) {
                        bits = test;
                    }
                }
                max = Math.max(max, bits | data[i]);
            }

            io.cache.append(max);
        }
    }

    /**
     * Bit operations
     */
    public static class BitOperator {
        public int bitAt(int x, int i) {
            return (x >> i) & 1;
        }

        public int bitAt(long x, int i) {
            return (int) ((x >> i) & 1);
        }

        public int setBit(int x, int i, boolean v) {
            if (v) {
                x |= 1 << i;
            } else {
                x &= ~(1 << i);
            }
            return x;
        }

        public long setBit(long x, int i, boolean v) {
            if (v) {
                x |= 1L << i;
            } else {
                x &= ~(1L << i);
            }
            return x;
        }

        /**
         * Determine whether x is subset of y
         */
        public boolean subset(long x, long y) {
            return intersect(x, y) == x;
        }

        /**
         * Merge two set
         */
        public long merge(long x, long y) {
            return x | y;
        }

        public long intersect(long x, long y) {
            return x & y;
        }

        public long differ(long x, long y) {
            return x - intersect(x, y);
        }
    }

    public static class Container {
        int a = -1;
        int b = -1;

        public int getMin() {
            return Math.min(a, b);
        }

        public void populate(int x) {
            if (a == x || b == x) {
                return;
            } else if (a == -1) {
                a = x;
            } else if (b == -1) {
                b = x;
            } else if (a < b && a < x) {
                a = x;
            } else if (b < a && b < x) {
                b = x;
            }
        }
    }

    public static class FastIO {
        public final StringBuilder cache = new StringBuilder(1 << 13);
        private final InputStream is;
        private final OutputStream os;
        private final Charset charset;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastIO(InputStream is, OutputStream os, Charset charset) {
            this.is = is;
            this.os = os;
            this.charset = charset;
        }

        public FastIO(InputStream is, OutputStream os) {
            this(is, os, Charset.forName("ascii"));
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public long readLong() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            long val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public double readDouble() {
            boolean sign = true;
            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+';
                next = read();
            }

            long val = 0;
            while (next >= '0' && next <= '9') {
                val = val * 10 + next - '0';
                next = read();
            }
            if (next != '.') {
                return sign ? val : -val;
            }
            next = read();
            long radix = 1;
            long point = 0;
            while (next >= '0' && next <= '9') {
                point = point * 10 + next - '0';
                radix = radix * 10;
                next = read();
            }
            double result = val + (double) point / radix;
            return sign ? result : -result;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

        public int readLine(char[] data, int offset) {
            int originalOffset = offset;
            while (next != -1 && next != '\n') {
                data[offset++] = (char) next;
                next = read();
            }
            return offset - originalOffset;
        }

        public int readString(char[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (char) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public int readString(byte[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (byte) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public char readChar() {
            skipBlank();
            char c = (char) next;
            next = read();
            return c;
        }

        public void flush() throws IOException {
            os.write(cache.toString().getBytes(charset));
            os.flush();
            cache.setLength(0);
        }

        public boolean hasMore() {
            skipBlank();
            return next != -1;
        }
    }

    public static class Debug {
        private boolean allowDebug;

        public Debug(boolean allowDebug) {
            this.allowDebug = allowDebug;
        }

        public void assertTrue(boolean flag) {
            if (!allowDebug) {
                return;
            }
            if (!flag) {
                fail();
            }
        }

        public void fail() {
            throw new RuntimeException();
        }

        public void assertFalse(boolean flag) {
            if (!allowDebug) {
                return;
            }
            if (flag) {
                fail();
            }
        }

        private void outputName(String name) {
            System.out.print(name + " = ");
        }

        public void debug(String name, int x) {
            if (!allowDebug) {
                return;
            }

            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, long x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, double x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, int[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, long[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, double[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, Object x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, Object... x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.deepToString(x));
        }
    }
}


import java.io.*;
import java.util.*;

public class A {
    FastScanner in;
    PrintWriter out;

    final int M = 21;
    final int MAX = 1 << M;

    void update(int[][] res, int mask, int pos) {
        if (res[0][mask] > pos) {
            res[1][mask] = res[0][mask];
            res[0][mask] = pos;
        } else if (res[1][mask] > pos && res[0][mask] != pos) {
            res[1][mask] = pos;
        }
    }

    int[][] getFirst(int[] a) {
        int[][] res = new int[2][MAX];
        Arrays.fill(res[0], a.length);
        Arrays.fill(res[1], a.length);
        for (int i = 0; i < a.length; i++) {
            update(res, a[i], i);
        }
        for (int mask = MAX - 1; mask > 0; mask--) {
            for (int i = 0; i < M; i++) {
                if (((1 << i) & mask) != 0) {
                    update(res, mask ^ (1 << i), res[0][mask]);
                    update(res, mask ^ (1 << i), res[1][mask]);
                }
            }
        }
        return res;
    }

    void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int[][] first = getFirst(a);
        for (int i = 0, j = n - 1; i < j; i++, j--) {
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        int[][] last = getFirst(a);
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < last[i].length; j++) {
                last[i][j] = a.length - last[i][j] - 1;
            }
        }
        int ans = 0;
        for (int bit = M - 1; bit >= 0; bit--) {
            int checkAns = ans | (1 << bit);
            boolean ok = false;
            for (int sub = checkAns; ; sub = (sub - 1) & checkAns) {
                int posLeft = first[0][sub];
                int needRight = checkAns ^ sub;
                int posRight = last[1][needRight];
                if (posLeft < posRight) {
                    ok = true;
                    break;
                }
                if (sub == 0) {
                    break;
                }
            }
            if (ok) {
                ans |= 1 << bit;
            }
        }
        out.println(ans);
    }

    void run() {
        try {
            in = new FastScanner(new File("A.in"));
            out = new PrintWriter(new File("A.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new A().runIO();
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author ilyakor
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    TaskF solver = new TaskF();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskF {

    static final int M = 21;
    int[] u;
    int[] d;
    int[] q;
    int gen;
    int ql;
    int qr;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
      u = new int[1 << M];
      d = new int[1 << M];
      q = new int[(1 << M) + 10];
      gen = 1;
      int n = in.nextInt();
      int[] a = new int[n];
      for (int i = 0; i < n; ++i) {
        a[i] = in.nextInt();
      }
      int res = 0;
      for (int i = n - 1; i >= 0; --i) {
        if (i <= n - 3) {
          int cur = calc(a[i]);
          if (cur > res) {
            res = cur;
          }
        }
        add(a[i]);
      }
      out.printLine(res);
    }

    private int calc(int x) {
      int mask = 0;
      for (int i = M - 1; i >= 0; --i) {
        if ((x >> i) % 2 == 1) {
          continue;
        }
        int nm = mask ^ (1 << i);
        if (d[nm] >= 2) {
          mask = nm;
        }
      }
      return x | mask;
    }

    private void add(int x) {
      if (d[x] >= 2) {
        return;
      }
      ++gen;
      ql = 0;
      qr = 0;
      q[ql++] = x;
      u[x] = gen;
      ++d[x];
      while (ql > qr) {
        int y = q[qr++];
        for (int i = 0; i < M; ++i) {
          if ((y >> i) % 2 == 1) {
            int z = y ^ (1 << i);
            if (u[z] == gen) {
              continue;
            }
            if (d[z] >= 2) {
              continue;
            }
            d[z]++;
            u[z] = gen;
            q[ql++] = z;
          }
        }
      }
    }

  }

  static class OutputWriter {

    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
      for (int i = 0; i < objects.length; i++) {
        if (i != 0) {
          writer.print(' ');
        }
        writer.print(objects[i]);
      }
    }

    public void printLine(Object... objects) {
      print(objects);
      writer.println();
    }

    public void close() {
      writer.close();
    }

  }

  static class InputReader {

    private InputStream stream;
    private byte[] buffer = new byte[10000];
    private int cur;
    private int count;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public static boolean isSpace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public int read() {
      if (count == -1) {
        throw new InputMismatchException();
      }
      try {
        if (cur >= count) {
          cur = 0;
          count = stream.read(buffer);
          if (count <= 0) {
            return -1;
          }
        }
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      return buffer[cur++];
    }

    public int readSkipSpace() {
      int c;
      do {
        c = read();
      } while (isSpace(c));
      return c;
    }

    public int nextInt() {
      int sgn = 1;
      int c = readSkipSpace();
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res = res * 10 + c - '0';
        c = read();
      } while (!isSpace(c));
      res *= sgn;
      return res;
    }

  }
}


import java.util.*;
import java.io.*;

public class Solution{

	public static Integer INT(String s){
		return Integer.parseInt(s);
	}

	public static Long LONG(String s){
		return Long.parseLong(s);
	}

	//====================================================================================================================

	public static void main(String args[]) throws IOException {

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));	Scanner in=new Scanner(System.in); StringBuilder out=new StringBuilder();

		int n=in.nextInt();

		int a[]=new int[n];
		for(int i=0; i<n; i++)
			a[i]=in.nextInt();

		System.out.println(solve(a, n));
	}

	public static int solve(int a[], int n) {

		int B=21, curr, mask, ans=0;

		int cnt[]=new int[1<<B];

		for(int i=n-1; i>=0; i--) {

			curr=mask=0;

			for(int j=B-1; j>=0; j--) {

				if((a[i]>>j&1)==1)
					curr|=(1<<j);
				else if(cnt[mask|(1<<j)]>=2) {
					curr|=(1<<j);
					mask|=(1<<j);
				}

			}

			if(i<n-2)
				ans=Math.max(ans, curr);
			add(cnt, a[i], B-1);
			cnt[a[i]]++;
		}

		return ans;
	}

	public static void add(int cnt[], int item, int B) {
		if(cnt[item]>=2 || B<0)
			return;
		add(cnt, item, B-1);
		if((item&(1<<B))!=0) {
			int item_=item^(1<<B);
			add(cnt, item_, B-1);
			cnt[item_]+=1;
		}
	}
}


import java.io.*;
import java.util.*;

public class Codeforces1208F {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int[] a = new int[n];
		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}

		//ok this is horrendous why is the time limit only 2 seconds
		final int SIZE = (1 << 21);

		//front[x] will be first index i such that a[i]&x = x
		int[] front = new int[SIZE];
		//back[x] will be last two indices i, j such that a[i]&x = x, a[j]&x = x;
		int[][] back = new int[SIZE][2];

		for (int i = 0; i < SIZE; i++) {
			front[i] = n;
			back[i][0] = -1;
			back[i][1] = -1;
		}

		//ok time for a bunch of BFS

		//ok let's first do it from the front
		int[] tracker = new int[SIZE];
		boolean[] found = new boolean[SIZE];
		int first = 0;
		int last = 1;
		for (int i = 0; i < n; i++) {
			if (!(found[a[i]])) {
				first = 0;
				last = 1;
				tracker[first] = a[i];
				found[a[i]] = true;
				front[a[i]] = i;
				while (first < last) {
					int val = tracker[first];
					for (int k = 0; k < 21; k++) {
						if ((val >> k)%2 == 1) {
							int r = val - (1<<k);
							if (!found[r]) {
								found[r] = true;
								tracker[last] = r;
								last++;
								front[r] = i;
							}
						}
					}
					first++;
				}
			}
		}

		//ok now from the back
		for (int i = 0; i < SIZE; i++) {
			found[i] = false;
		}
		for (int i = n-1; i >= 0; i--) {
			if (back[a[i]][1] == -1) {
				first = 0;
				last = 1;
				tracker[first] = a[i];
				if (found[a[i]]) {
					back[a[i]][1] = i;
				}
				else {
					found[a[i]] = true;
					back[a[i]][0] = i;
				}
				while (first < last) {
					int val = tracker[first];
					for (int k = 0; k < 21; k++) {
						if ((val >> k)%2 == 1) {
							int r = val - (1<<k);
							if (!found[r]) {
								found[r] = true;
								back[r][0] = i;
								tracker[last] = r;
								last++;
							}
							else if ((back[r][1] == -1) && (back[r][0] != i)) {
								back[r][1] = i;
								tracker[last] = r;
								last++;
							}
						}
					}
					first++;
				}
			}
		}

		//ok now it is time for the binary search
		int val = 1;
		for (int k = 20; k >= 0; k--) {
			boolean bool = false;
			for (int i = 0; i <= val; i++) {
				if (((val&i) == i) && (front[i<<k] < back[(val-i)<<k][1])) {
					bool = true;
				}
			}
			if (k > 0) {
				if (bool) {
					val = 2*val + 1;
				}
				else {
					val = 2*val - 1;
				}
			}
			else if (!bool) {
				val--;
			}
		}
		System.out.println(val);
	}
}


/**
 * BaZ :D
 */
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import java.math.BigInteger;
public class Main
{
    static MyScanner scan;
    static PrintWriter pw;
    static long MOD = 998244353;//1_000_000_007;
    static long INF = 1_000_000_000_000_000_000L;
    static long inf = 2_000_000_000;
    public static void main(String[] args) {
        new Thread(null,null,"BaZ",1<<25)
        {
            public void run()
            {
                try
                {
                    solve();
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }
    static int dp[][], arr[];
    static void solve() throws IOException
    {
        //initIo(true);
        initIo(false);
        StringBuilder sb = new StringBuilder();
        int MAX = (1<<21) - 1;
        dp = new int[MAX+1][2];
        for(int i=0;i<=MAX;++i) {
            dp[i][0] = dp[i][1] = -1;
        }
        int n = ni();
        arr = new int[n];
        for(int i=0;i<n;++i) {
            arr[i] = ni();
        }
        for(int i=n-1;i>=0;--i) {
            if(dp[arr[i]][0]==-1) {
                dp[arr[i]][0] = i;
            }
            else if(dp[arr[i]][1]==-1) {
                dp[arr[i]][1] = i;
            }
        }
        for(int mask=MAX;mask>=0;--mask) {
            for(int bit=0;bit<21;++bit) {
                if((mask&(1<<bit))==0) {
                    assign(mask, dp[mask][0], dp[mask][1], dp[mask|(1<<bit)][0], dp[mask|(1<<bit)][1]);
                }
            }
        }
//        for(int i=0;i<16;++i) {
//            pl("mask: "+i+" right1: "+dp[i][1]+" right2: "+dp[i][0]);
//        }
        int ans = Integer.MIN_VALUE;
        for(int i=0;i<n;++i) {
            int now = 0;
            for(int bit=20;bit>=0;--bit) {
                if((arr[i]&(1<<bit))==0) {
                    if(dp[now|(1<<bit)][1]>i) {
                        now|=(1<<bit);
                    }
                }
            }
            ans = max(ans, arr[i]|now);
        }
        pl(ans);
        pw.flush();
        pw.close();
    }
    static void assign(int index, int ...val) {
        int max1 = -1, max2 = -1;
        for(int e : val) {
            if(e>max1) {
                max2 = max1;
                max1 = e;
            }
            else if(e>max2 && e<max1) {
                max2 = e;
            }
        }
        dp[index][0] = max1;
        dp[index][1] = max2;
    }
    static void initIo(boolean isFileIO) throws IOException {
        scan = new MyScanner(isFileIO);
        if(isFileIO) {
            pw = new PrintWriter("/Users/amandeep/Desktop/output.txt");
        }
        else {
            pw = new PrintWriter(System.out, true);
        }
    }
    static int ni() throws IOException
    {
        return scan.nextInt();
    }
    static long nl() throws IOException
    {
        return scan.nextLong();
    }
    static double nd() throws IOException
    {
        return scan.nextDouble();
    }
    static String ne() throws IOException
    {
        return scan.next();
    }
    static String nel() throws IOException
    {
        return scan.nextLine();
    }
    static void pl()
    {
        pw.println();
    }
    static void p(Object o)
    {
        pw.print(o+" ");
    }
    static void pl(Object o)
    {
        pw.println(o);
    }
    static void psb(StringBuilder sb)
    {
        pw.print(sb);
    }
    static void pa(String arrayName, Object arr[])
    {
        pl(arrayName+" : ");
        for(Object o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, int arr[])
    {
        pl(arrayName+" : ");
        for(int o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, long arr[])
    {
        pl(arrayName+" : ");
        for(long o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, double arr[])
    {
        pl(arrayName+" : ");
        for(double o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, char arr[])
    {
        pl(arrayName+" : ");
        for(char o : arr)
            p(o);
        pl();
    }
    static void pa(String listName, List list)
    {
        pl(listName+" : ");
        for(Object o : list)
            p(o);
        pl();
    }
    static void pa(String arrayName, Object[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(Object o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, int[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(int o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, long[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(long o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, char[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(char o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, double[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(double o : arr[i])
                p(o);
            pl();
        }
    }
    static class MyScanner
    {
        BufferedReader br;
        StringTokenizer st;
        MyScanner(boolean readingFromFile) throws IOException
        {
            if(readingFromFile) {
                br = new BufferedReader(new FileReader("/Users/amandeep/Desktop/input.txt"));
            }
            else {
                br = new BufferedReader(new InputStreamReader(System.in));
            }
        }
        String nextLine()throws IOException
        {
            return br.readLine();
        }
        String next() throws IOException
        {
            if(st==null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }
        double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
    }
}


/**
 * BaZ :D
 */
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import java.math.BigInteger;
public class Main
{
    static MyScanner scan;
    static PrintWriter pw;
    static long MOD = 998244353;//1_000_000_007;
    static long INF = 1_000_000_000_000_000_000L;
    static long inf = 2_000_000_000;
    public static void main(String[] args) {
        new Thread(null,null,"BaZ",1<<25)
        {
            public void run()
            {
                try
                {
                    solve();
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }
    static int dp[][];
    static void solve() throws IOException
    {
        //initIo(true);
        initIo(false);
        StringBuilder sb = new StringBuilder();
        int MAX = (1<<21) - 1;
        dp = new int[MAX][21];
        pl(0);
        pw.flush();
        pw.close();
    }
    static void initIo(boolean isFileIO) throws IOException {
        scan = new MyScanner(isFileIO);
        if(isFileIO) {
            pw = new PrintWriter("/Users/amandeep/Desktop/output.txt");
        }
        else {
            pw = new PrintWriter(System.out, true);
        }
    }
    static int ni() throws IOException
    {
        return scan.nextInt();
    }
    static long nl() throws IOException
    {
        return scan.nextLong();
    }
    static double nd() throws IOException
    {
        return scan.nextDouble();
    }
    static String ne() throws IOException
    {
        return scan.next();
    }
    static String nel() throws IOException
    {
        return scan.nextLine();
    }
    static void pl()
    {
        pw.println();
    }
    static void p(Object o)
    {
        pw.print(o+" ");
    }
    static void pl(Object o)
    {
        pw.println(o);
    }
    static void psb(StringBuilder sb)
    {
        pw.print(sb);
    }
    static void pa(String arrayName, Object arr[])
    {
        pl(arrayName+" : ");
        for(Object o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, int arr[])
    {
        pl(arrayName+" : ");
        for(int o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, long arr[])
    {
        pl(arrayName+" : ");
        for(long o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, double arr[])
    {
        pl(arrayName+" : ");
        for(double o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, char arr[])
    {
        pl(arrayName+" : ");
        for(char o : arr)
            p(o);
        pl();
    }
    static void pa(String listName, List list)
    {
        pl(listName+" : ");
        for(Object o : list)
            p(o);
        pl();
    }
    static void pa(String arrayName, Object[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(Object o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, int[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(int o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, long[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(long o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, char[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(char o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, double[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(double o : arr[i])
                p(o);
            pl();
        }
    }
    static class MyScanner
    {
        BufferedReader br;
        StringTokenizer st;
        MyScanner(boolean readingFromFile) throws IOException
        {
            if(readingFromFile) {
                br = new BufferedReader(new FileReader("/Users/amandeep/Desktop/input.txt"));
            }
            else {
                br = new BufferedReader(new InputStreamReader(System.in));
            }
        }
        String nextLine()throws IOException
        {
            return br.readLine();
        }
        String next() throws IOException
        {
            if(st==null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }
        double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
    }
}


/**
 * BaZ :D
 */
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import java.math.BigInteger;
public class Main
{
    static MyScanner scan;
    static PrintWriter pw;
    static long MOD = 998244353;//1_000_000_007;
    static long INF = 1_000_000_000_000_000_000L;
    static long inf = 2_000_000_000;
    public static void main(String[] args) {
        new Thread(null,null,"BaZ",1<<25)
        {
            public void run()
            {
                try
                {
                    solve();
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }
    static int dp[][], arr[];
    static void solve() throws IOException
    {
        //initIo(true);
        initIo(false);
        StringBuilder sb = new StringBuilder();
        int MAX = (1<<21) - 1;
        dp = new int[MAX+1][2];
        for(int i=0;i<=MAX;++i) {
            dp[i][0] = dp[i][1] = -1;
        }
        int n = ni();
        arr = new int[n];
        for(int i=0;i<n;++i) {
            arr[i] = ni();
        }
        for(int i=n-1;i>=0;--i) {
            if(dp[arr[i]][0]==-1) {
                dp[arr[i]][0] = i;
            }
            else if(dp[arr[i]][1]==-1) {
                dp[arr[i]][1] = i;
            }
        }
        for(int mask=MAX;mask>=0;--mask) {
            for(int bit=0;bit<21;++bit) {
                if((mask&(1<<bit))==0) {
                    assign(mask, dp[mask][0], dp[mask][1], dp[mask|(1<<bit)][0], dp[mask|(1<<bit)][1]);
                }
            }
        }
        int ans = Integer.MIN_VALUE;
        for(int i=0;i<n;++i) {
            int now = 0;
            for(int bit=20;bit>=0;--bit) {
                if((arr[i]&(1<<bit))==0) {
                    if(dp[now|(1<<bit)][1]>i) {
                        now|=(1<<bit);
                    }
                }
            }
            if(n-1-i>=2) {
                ans = max(ans, arr[i]|now);
            }
        }
        pl(ans);
        pw.flush();
        pw.close();
    }
    static void assign(int index, int ...val) {
        int max1 = -1, max2 = -1;
        for(int e : val) {
            if(e>max1) {
                max2 = max1;
                max1 = e;
            }
            else if(e>max2 && e<max1) {
                max2 = e;
            }
        }
        dp[index][0] = max1;
        dp[index][1] = max2;
    }
    static void initIo(boolean isFileIO) throws IOException {
        scan = new MyScanner(isFileIO);
        if(isFileIO) {
            pw = new PrintWriter("/Users/amandeep/Desktop/output.txt");
        }
        else {
            pw = new PrintWriter(System.out, true);
        }
    }
    static int ni() throws IOException
    {
        return scan.nextInt();
    }
    static long nl() throws IOException
    {
        return scan.nextLong();
    }
    static double nd() throws IOException
    {
        return scan.nextDouble();
    }
    static String ne() throws IOException
    {
        return scan.next();
    }
    static String nel() throws IOException
    {
        return scan.nextLine();
    }
    static void pl()
    {
        pw.println();
    }
    static void p(Object o)
    {
        pw.print(o+" ");
    }
    static void pl(Object o)
    {
        pw.println(o);
    }
    static void psb(StringBuilder sb)
    {
        pw.print(sb);
    }
    static void pa(String arrayName, Object arr[])
    {
        pl(arrayName+" : ");
        for(Object o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, int arr[])
    {
        pl(arrayName+" : ");
        for(int o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, long arr[])
    {
        pl(arrayName+" : ");
        for(long o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, double arr[])
    {
        pl(arrayName+" : ");
        for(double o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, char arr[])
    {
        pl(arrayName+" : ");
        for(char o : arr)
            p(o);
        pl();
    }
    static void pa(String listName, List list)
    {
        pl(listName+" : ");
        for(Object o : list)
            p(o);
        pl();
    }
    static void pa(String arrayName, Object[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(Object o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, int[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(int o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, long[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(long o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, char[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(char o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, double[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(double o : arr[i])
                p(o);
            pl();
        }
    }
    static class MyScanner
    {
        BufferedReader br;
        StringTokenizer st;
        MyScanner(boolean readingFromFile) throws IOException
        {
            if(readingFromFile) {
                br = new BufferedReader(new FileReader("/Users/amandeep/Desktop/input.txt"));
            }
            else {
                br = new BufferedReader(new InputStreamReader(System.in));
            }
        }
        String nextLine()throws IOException
        {
            return br.readLine();
        }
        String next() throws IOException
        {
            if(st==null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }
        double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
    }
}