Counting the minimum number of blocks to remove to form a triangular temple
Your code is not working for some cases.
Consider for example input 1 1 2 2 4.
The answer should be 6, but your code returns 1.