Murthal Parantha

I’m getting wrong answer for every test case.
But for given input
10 4
1 2 3 4
I’m getting correct answer. Please Help!
code link: https://ide.codingblocks.com/s/232453