Getting wa in sticks

please tell me where i’m wrong

Your case is failing when there are 4 sticks of the biggest no. I.e. that no. Can make square .
Eg. test case
7 7 7 7 4 4 3 3
The answer is 49 as 7 can make all the 4 sides and a square is also a rectangle


oh, thanks i’m solving this problem in the perspective of rectangle and neglecting square

i have optimised my solution but still getting wa