DWITE Contest

Test Case for Question #2 in DWITE 2011-2012 High School Round 1

Contest: DWITE 2011-2012 High School Round 1
Question: #2
Input File: DATA2.txt
Output File: OUT2.txt


Input

1
10
10
1
2
3
4
5
6
7
8
9
15
20
123
999
162
898
939
234
789
987
235
456
564
234
200
504
923
656
453
123
1000
1
50
1
10
434
3
23
54
2
53
59
342
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
123
342
999
1
1
1
1
1
5
1000
900
800
700
600




Output

0
15
3039
10262
300