Codeforces Round 198 (Div. 1)


A. Tourist Problem
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 5
Output
22 3
----------------------------------------------------------------------------------------------------
B. Bubble Sort Graph
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 1 2
Output
2
----------------------------------------------------------------------------------------------------
C. Iahub and Permutations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
-1 -1 4 3 -1
Output
2
----------------------------------------------------------------------------------------------------
D. Iahub and Xors
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
2 1 1 2 2 1
2 1 3 2 3 2
2 3 1 3 3 3
1 2 2 3 3
1 2 2 3 2
Output
3
2
----------------------------------------------------------------------------------------------------
E. Candies Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 6 9
Output
2
2 3
1 3
Input
3
0 1 0
Output
-1
Input
4
0 1 1 0
Output
0
----------------------------------------------------------------------------------------------------
