Xor Sum#11819

Xor Sum

4 seconds
128 megabytes
Hard

Print the answer for the following code:

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        long long sum = 0;
        for (int j = i; j <= n; j++) {
            sum += a[j];
            ans ^= sum;
        }
    }
    cout << ans;

Input

The first line contains a single integer n~(1 \le n \le 3 \cdot 10^5) — the number of elements in the array.

The second line contains integers a_1, a_2, ..., a_n~(0 \le a_i \le 10^9).

Output

Print the answer for the given code.

Examples

Example 1

Loading
Loading