406106: GYM102267 K Birthday Puzzle
Description
Today is the Birthday of a beautiful girl, she's happy and she's telling her friends loudly to bring her birthday gifts. One of her best friends who is fond of puzzles decided to bring her a very special gift, a magic box, this box cannot be opened unless the beautiful girl solves the mysterious puzzle written on the box and writes the answer on a small piece of paper under where the puzzle is written.
"You are given an array $$$a$$$, the answer is obtained by doing OR operation to the numbers in each subset of array $$$a$$$, then by summing all the subset ORing results". Help the beautiful girl to find the answer so she can open the magic box and continue celebrating her blessed birthday.
InputThe first line contains integer $$$n(1\le n \le 20),$$$ the size for array $$$a$$$ The second line contains $$$n$$$ integers, $$$a_{i}(1 \le a_{i} \le 10^5)$$$ the array $$$a$$$ elements
OutputHelp the beautiful girl to find the answer for the puzzle.
ExampleInput3 1 2 3Output
18Note
Note: a subset of an array $$$a$$$ is another array that can be obtained by removing zero or more elements from $$$a$$$.
The first sample subsets:
1
2
3
1|2 = 3
1|3 = 3
2|3 = 3
1|2|3 = 3
Answer = 1+2+3+3+3+3+3 = 18
Where | is the OR operation.
For more information about the OR operation use this link: https://en.wikipedia.org/wiki/Bitwise_operation#OR