시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB111100.000%

문제

bobo has a sequence $a_1, a_2, \dots, a_n$. He would like to choose $k$ consecutive elements and maximize the value $S$ that is defined as their maximum plus their bitwise or.

For all $1 \leq k \leq n$, find the maximal value bobo can achieve.

입력

The first line contains an integer $n$ ($1 \leq n \leq 10^5$).

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \leq a_i < 2^{16}$).

출력

$n$ integers, where the $i$-th integer is maximal $S$ for $k=i$.

예제 입력 1

3
1 0 2

예제 출력 1

4
4
5