Bob was given N integers by his teacher. He was supposed to make a expression out of them without changing the order of integers. So he decided to use 2 types of operators: "|"(also known as Bitwise Or ) and "+". He decided to put exactly one operator between every consecutive integers. Thus he would use N−1 operators to form a valid mathematical expression from the N integers. But as Bob is feeling very sleepy, he might use any of the 2 operators with equal probability at any of the valid places.
His teacher was perplexed by this random behavior and wondered what is the Expected value of the Random Expression thus created by her student. Note that Bitwise OR has higher precedence than addition operator.
Input Format
The first line consists of an integer, N.
Next line follows with N integers.
Output Format
Print P∗Q−1mod 109+7, where PQ is the expected value of expression expressed as an irreducible fraction.
Input Constraints
1≤N≤106
0≤all integers≤109
The different ways are:
1+2+3=6
1+2|3=4
1|2+3=6
1|2|3=3
All these ways have probability = 14
So the Expected value = 6×14+4×14+6×14+3×14=194≡750000010 mod 109+7.