An integer and an array of non-negative integers a_1,a_2,\ldots,a_n are given. All elements of the array are less than 2^b.
Let's define f(s, p) (1\le s\le n, 0\le p < b) as the result of the following pseudocode:
res = 0
x = power(2, p)
for i = s to n:
if ((x AND a[i]) == 0):
x = (x OR a[i])
res = res + i
return resHere, "power(2, p)" denotes 2^p, "AND" denotes the bitwise AND operation, and "OR" denotes the bitwise OR operation.
The bitwise AND of non-negative integers and is equal to a non-negative integer, in which the binary representation has a one at a certain position only if both binary representations of and have ones at that position. For example, 3_{10} AND 5_{10} = 0011_{2} AND 0101_{2} = 0001_{2} = 1_{10}.
The bitwise OR of non-negative integers and is equal to a non-negative integer, in which the binary representation has a zero at a certain position only if both binary representations of and have zeros at that position. For example, 3_{10} OR 5_{10} = 0011_{2} OR 0101_{2} = 0111_{2} = 7_{10}.
For each from to , find
The first line contains two integers and (1 \leq n \leq 10^5, 1 \leq b \leq 20) — the length of array and the limit on the elements of the array, respectively.
The second line contains integers a_1, a_2, \ldots, a_n (0 \leq a_i < 2^b) — the elements of array .
Output integers — the required values.
Example 1
Example 2
In the first example, f(1,0)=1+2+5=8, f(1,1)=1+3+5=9, f(1,2)=1+2+3=6, and the first of the required values is equal to 8+9+6 = 23.
( points): n \leq 2\,000;
( points): a_i = 2^k, where is an integer;
( points): b \leq 8;
( points): b \leq 12;
( points): b \leq 16;
( points): without additional constraints.