Importance of time

can you please help me correct my code.
my code is working for the specified input but so submitting it is reporting code as wrong .

Consider a case:
7
5 29 12 16 25 17 18
17 18 25 12 16 29 5

Expected O/p:
19
Your o/p
13

Refer the approach from here Importance_of_Time

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.