Kindly check the code
hello @EkanshJain2323 i checked ur code ,the logic is not correct.
example-> 6 1 2 3 2 2 4