ABC interview question

Program logic based on the array