Input
2 3 1 1 1 1 1 1
Output
6
5 4 9 -2 -1 3 -10 -5 1 -4 1 -1 2 -2 3 0 0 -1 2 2 -1 2
8
Nguồn: 3D '1819