time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Example
E.
7 5 2
2 15 6 3 7 5 6
1 2
3 7
5 5
7 7
3 5
Output
2
12
7
6
9