Codeforces Round 446 (Div. 1)


A. Pride
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 2 3 4 6
Output
5
Input
4
2 4 6 8
Output
-1
Input
3
2 6 9
Output
4
----------------------------------------------------------------------------------------------------
B. Gluttony
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
Output
2 1 
Input
4
1000 100 10 1
Output
100 1 1000 10
----------------------------------------------------------------------------------------------------
C. Envy
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 7
1 2 2
1 3 2
2 3 1
2 4 1
3 4 1
3 5 2
4 5 2
4
2 3 4
3 3 4 5
2 1 7
2 1 2
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
D. Sloth
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
2 3
3 4
Output
8
Input
5
1 2
2 3
3 4
3 5
Output
0
Input
8
1 2
2 3
3 4
1 5
5 6
6 7
1 8
Output
22
----------------------------------------------------------------------------------------------------
E. Lust
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
5 5
Output
5
Input
1 10
80
Output
10
Input
2 2
0 0
Output
500000003
Input
9 4
0 11 12 9 20 7 8 18 2
Output
169316356
----------------------------------------------------------------------------------------------------
