You have been given an array of N integers A1,A2..AN. You have to find simple sum for this array. Simple Sum is defined as ∑i=Ni=1∑j=Nj=imax(Ai,Ai+1,…,Aj)∗(Ai|Aj). | denotes the bitwise OR operator.
INPUT:
First line of input consists of integer N. Next line of input consists of N integers A1,A2..AN.
OUTPUT:
Print the simple sum of given array.
CONSTRAINTS:
1 ≤ N ≤ 105
1 ≤ Ai ≤ 104
If you apply the given formula for the the array, you will get answer as 209.