Richard wants to demonstrate that there are things far worse than Fenwick in terms of things to remember, and the first example he gave was heap Dijkstra.
To demonstrate this, he wants a problem that has many edges, but doesn't benefit too much from fast I/O. So a natural candidate is https://szkopul.edu.pl/problemset/problem/ROXsaseQWYR11jbNvCgM19Er/site/?key=statement.
The algorithm in that problem is basically to construct a graph on the modulus against , and then do shortest path to look for the smallest number in each modulus that could be constructed.
Your job will be to solve this problem with some tuned bounds.
Input Specification
The first line contains a single integer, .
lines follow, each containing a single integer .
You may assume and that .
Furthermore, .
Output Specification
Let be the smallest value that can be attained that is the sum of some multiset of values that is equivalent to . Print the XOR of all for .
It is guaranteed that is well-defined.
Sample Input
6
10
1
11
22
33
478154081019
Sample Output
1
Comments