#K81157. Bitwise Maximum Binary Construction

    ID: 35691 Type: Default 1000ms 256MiB

Bitwise Maximum Binary Construction

Bitwise Maximum Binary Construction

You are given a list of non-negative integers. Your task is to construct a new integer by taking the maximum bit in each column of the binary representations of these integers. In other words, first convert all integers to their binary representation with equal length (by padding with zeros on the left if necessary). Then, for each column (from the most significant bit to the least significant), determine the maximum digit (either 0 or 1) among all numbers. Finally, combine these bits to form a new binary number and output its decimal representation.

For example, given the list [3, 7, 8]:
- Convert to binary with equal length: 3 becomes 0011, 7 becomes 0111, and 8 becomes 1000 (if padded to 4 bits).
- Taking the maximum of each column: max(0,0,1)=1, max(0,1,0)=1, max(1,1,0)=1, max(1,1,0)=1, forming the binary string "1111", which is 15 in decimal.

inputFormat

The first line of input contains an integer n (1 ≤ n ≤ 10^5), representing the number of integers. The second line contains n space-separated non-negative integers.

outputFormat

Output a single integer which is the result obtained after constructing the new binary number via column-wise maximum.## sample

3
3 7 8
15