Alchembit Exam
시간 제한1초메모리 제한2048 MB
인접한 포션 구간을 합치면서 그 구간의 비트 AND 값을 점수로 얻을 때, 얻을 수 있는 최대 점수를 구한다.
문제
As a modern alchemy student, you are taking an exam in Alchembit, a hybrid between alchemy and modern technology. In the exam, you are given potions (numbered from to ) where potion has a potency of an integer . You start the exam with a score of .
You can increase your score by doing the following procedure.
- Suppose there are potions remaining. Choose an interval where .
- By choosing the interval , your score will be increased by A\_l \\,\\&\\, A\_{l+1} \\,\\&\\, \dots \\,\\&\\, A\_r, where the symbol \\& represents the bitwise AND operator.
- Next, fuse potions into one new potion with a potency of A\_l \\,\\&\\, A\_{l+1} \\,\\&\\, \dots \\,\\&\\, A\_r.
- The potions are then renumbered as follows: the newly fused potion becomes potion , and potions are renumbered as . Potions numbered remain unchanged.
For example, if you have potions with potencies , and you choose interval , then your score will be increased by 12 \\,\\&\\, 10 = 8. Then, potions and are fused into a new potion with a potency of 12 \\,\\&\\, 10 = 8. After the renumbering procedure (step 4), A becomes .
You can perform the above procedure until there is only one potion left. Determine the maximum score that you can achieve.
입력
The first line consists of an integer ().
The second line consists of integers ().
출력
Output a single integer representing the maximum score that you can get.