Codeforces problem c doubt

can anyone please tell me why am i getting tle in the following problem:
here is the question
my solution
my approach: start from ending, you have two options either two select the current element and reverse the sign and go to (i-1) or skip the current element and retain the sign and go to (i-1).