QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#14631. XOR Sum

Statistics

Xiao Ming from Jiali Middle School loves math competitions. Many problems in math competitions are related to the contiguous subsequences of a sequence. Therefore, for a given sequence, finding the sum of all its contiguous subsequences is very simple for Xiao Ming. However, today Xiao Ming encountered a difficult sequence problem. This problem not only requires you to quickly find the sum of all contiguous subsequences but also to quickly find the XOR sum of all contiguous subsequences. Xiao Ming can quickly find the sum of all contiguous subsequences, but he wants to test you: without telling you the contiguous subsequences, can you quickly find the XOR sum of all contiguous subsequences of the sequence?

Input

The first line contains an integer $n$, representing the number of elements in the sequence. The second line contains $n$ integers $a_1, a_2, a_3, \dots, a_n$, representing the sequence. $0 \le a_1, a_2, \dots, a_n$, $0 \le a_1 + a_2 + \dots + a_n \le 10^6$.

Output

Output the XOR sum of all contiguous subsequences of this sequence.

Examples

Input 1

3
1 2 3

Output 1

0

Note

The sequence $1, 2, 3$ has $6$ contiguous subsequences, which are $1, 2, 3, 1+2=3, 2+3=5, 1+2+3=6$. Then $1 \oplus 2 \oplus 3 \oplus 3 \oplus 5 \oplus 6 = 0$.

Constraints

For $20\%$ of the data, $1 \le n \le 1000$. For $100\%$ of the data, $1 \le n \le 10^5$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.