Min Query I. Getting TLE, code review required

I don’t know why it is getting TLE. Please review the code.