Given an array

**A**consisting of**N**integers -**A**. You have to find the value of_{1}, A_{2}....A_{N}**Σ MAX(i,j) * F(i,j)**where**1 ≤ i < j ≤ N**.

**MAX(i,j)**is defined as

**max(A**.

_{i},A_{i+1}...A_{j})**F(i,j)**is defined as:

**F(i,j)**will be 1 if**(A**or_{i}&A_{j}) = A_{j}**(A**_{i}&A_{j}) = A_{i}**F(i,j)**will be 0, otherwise.

**&**denotes the bitwise AND operator.

### Input

The first line of input will consist of integer

**N**.
The next line of input will consists of

**N**integers**A**._{1}, A_{2}....A_{N}### Output

Output the value of the above mentioned expression in a single line.

### Constraints and Subtasks

**Subtask #1 : (40 points)**

**1 ≤ N ≤ 10**^{3}**0 ≤ A**_{i}< 2^{14}

**Subtask #2 : (60 points)**

**1 ≤ N ≤ 10**^{5}**0 ≤ A**_{i}< 2^{14}

### Example

**Input:**
`5
2 3 7 4 1`
**Output:**
`38`

### Explanation

The value of

**F(i,j)**will be 1 for (1,2),(1,3),(2,3),(2,5),(3,4),(3,5).Therefore, answer will be**MAX(1,2) + MAX(1,3) + MAX(2,3) + MAX(2,5) + MAX(3,4) + MAX(3,5) = 38.**