#include <bits/stdc++.h>   template <typename T>   void scan(T &x) {     x = 0;     bool _ = 0;     T c = getchar();     _ = c == 45;     c = _ ? getchar() : c;     while (c < 48 || c > 57) c = getchar();     for (; c < 48 || c > 57; c = getchar())       ;     for (; c > 47 && c < 58; c = getchar()) x = (x << 3) + (x << 1) + (c & 15);     x = _ ? -x : x;   }   template <typename T>   void printn(T n) {     bool _ = 0;     _ = n < 0;     n = _ ? -n : n;     char snum[65];     int i = 0;     do {       snum[i++] = n % 10 + 48;       n /= 10;     } while (n);     --i;     if (_) putchar(45);     while (i >= 0) putchar(snum[i--]);   }   template <typename First, typename... Ints>   void scan(First &arg, Ints &...rest) {     scan(arg);     scan(rest...);   }   template <typename T>   void print(T n) {     printn(n);     putchar(10);   }   template <typename First, typename... Ints>   void print(First arg, Ints... rest) {     printn(arg);     putchar(32);     print(rest...);   }   using namespace std;   using ll = long long;   const int MM = 505;   int n;   ll a[MM], ans;   int main() {     scan(n);     for (int i = 0; i < n; i++) {       scan(a[i]);     }     for (int i = 0; i < n; i++) {       for (int j = 0; j <= i; j++) {         for (int k = 0; k <= j; k++) {           ans = max(ans, a[i] | a[j] | a[k]);         }       }     }     print(ans);   }   