B. Views Matter
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
You came to the exhibition and one exhibit has drawn your attention. It consists of nn stacks of blocks, where the ii-th stack consists of aiaiblocks resting on the surface.
The height of the exhibit is equal to mm. Consequently, the number of blocks in each stack is less than or equal to mm.
There is a camera on the ceiling that sees the top view of the blocks and a camera on the right wall that sees the side view of the blocks.
Find the maximum number of blocks you can remove such that the views for both the cameras would not change.
Note, that while originally all blocks are stacked on the floor, it is not required for them to stay connect