what is the reason for TLE in my code of LTIME29 ?

I was doing this question in yesterday’s lunchtime . The complexity of my solution matches with that of AC solutions . Still I can’t figure out the reason for getting TLE on the last subtask . Any help would be appreciated .

Here is the link to my solution .

Thanks in advance .

Calculate power in O(N) instead of O(NlogN), and you are good to go.