I am getting TLE

question –https://codeforces.com/problemset/problem/1399/C

my solution -https://ide.codingblocks.com/s/390348

i am getting TLE while i am doing within the constraints can you please tell me why i am getting TLE as the editorial videos on you tube did the same approach as mine

Hey @shivamgoel150
Add

        if(n==1){
            cout<<0<<endl;
            continue;
        }

After inputting vector