Bank Security Unification
시간 제한2초메모리 제한512 MB
라우터들의 부분 수열을 골라 인접한 값들의 비트 AND 합이 최대가 되도록 한다.
문제
The Bytelandian government has issued the Bank Security Unification law (or, shortly, the BSU law). The recent law regulates the usage of Wi-Fi routers in banks and other financial institutions.
According to the BSU law, all the Wi-Fi routers in a bank must be located in a straight line. Suppose that the -th router operates at the frequency . Denote the security of a connection between two adjacent routers as f\_{i}\\,\\, \\&\\,\\, f\_{i+1}, where \\& is the bitwise AND operation.
A set of at least two routers numbered must be chosen as active. All other routers will be kept inactive so that they can replace the active ones if any of them would break. Denote the security of the network as the sum of the securities of all connections between adjacent active routers. In other words, the security of the network is calculated as \sum\limits\_{j=1}^{k-1} f\_{i\_j}\\,\\,\\&\\,\\,f\_{i\_{j+1}}.
You are an employee of a large Bytelandian bank. Surely, the bank is obliged to comply with the BSU law. The routers are already placed in a line, and their placement cannot be changed. Now you want to choose some of the routers as active to maximize the security of the network.
입력
The first line contains an integer , denoting the number of Wi-Fi routers in the bank ().
The second line contains integers , where is the frequency of the -th router in the line ().
출력
Print the maximum possible security of the network.