Under construction

Still being built. Things may change

XOR Sum 3

Interview

Time limit2sMemory limit512 MB

Summary
Compute the XOR of every contiguous subsequence of A and print the sum of all those XOR values.
Level

Medium6 of 10

Topics
Bit manipulation, Prefix sum, Math
Solved
No attempts yet

Problem

The XOR sum of a sequence is the value obtained by XORing all of its elements together.

Given a sequence AA, write a program that computes the XOR sum of every contiguous subsequence of AA and outputs the total of all those XOR sums.

Input

The first line contains the length NN of the sequence. (1≤N≤100 000)(1 \le N \le 100\,000)

The second line contains the NN elements of AA, separated by spaces. Each element is a non-negative integer not exceeding 10910^9.

Output

Print the sum of the XOR sums of all contiguous subsequences of AA on the first line.

Examples1

  1. Example 1

    Input
    2
    1 2
    
    Expected output
    6