/* -*- coding: utf-8 -*- * * 2071.cc: No.2071 Shift and OR - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int K = 16; const int KBITS = 1 << K; /* typedef */ /* global variables */ int as[MAX_N]; bool dp[K][KBITS]; /* subroutines */ inline int shift(int x, int l) { return ((x >> l) | (x << (K - l))) & (KBITS - 1); } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); int m = 0; for (int i = 0; i < n; i++) if (as[i] > 0) as[m++] = as[i]; if (m >= K) { printf("%d\n", KBITS - 1); return 0; } dp[0][0] = true; for (int i = 0; i < m; i++) for (int j = 0; j < KBITS; j++) if (dp[i][j]) { for (int l = 0; l < K; l++) { int x = shift(as[i], l); dp[i + 1][j | x] = true; } } for (int x = KBITS - 1; x >= 0; x--) if (dp[m][x]) { printf("%d\n", x); break; } return 0; }