cswork / OAOpen practice workspace

NvidiaOA #3

Reconstruct Array from Prefix XOR

Estimated EasyJudge-ready

Topics (AI-labelled)Bits & Math

pref[i] is the XOR of elements 0 through i of the original array. Return the original array.

This site uses a standard input/output protocol.

Input

The first line contains N (1..100000), and the second line contains N values pref[i] (0..10⁹). Recovered values may exceed 10⁹ but are less than 2³⁰.

Output

Output N non-negative integers.

Example 1

Input:

4
2 2 5 6

Output:

2 0 7 3

Example 2

Input:

1
0

Output:

0

Example 3

Input:

3
7 0 7

Output:

7 7 7

Example notes

Example 1: the elements are 2, 0, 7, 3. Example 2: the only element is 0. Example 3: the prefix XORs of the original array 7, 7, 7 are 7, 0, 7.

Editorial

Loading solution…