2515 - Room

Input

Output

Examples

Input

3
3 4 5
4
1 3 3 5
3
117 170 197
3
210 229 247
3
185 185 222
4
5 45 89 113
4
13 52 53 68
0

Output

6
6
9900
22344
16428
1980
1800

Hint

3<=N<=6

1<=Ri<=300

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题