Start wide. Move the shorter wall inward — only that can improve area.
Input
9 1 8 6 2 5 4 8 3 7
Output
49
2 1 1
1