Maximum calorie
Submissions: 1526   Accuracy:

34.92%

  Difficulty: Medium   Marks: 4

Kapil always likes to eat and he has a diet plan. He has an array of elements indicating the calorie of food , he can consume in a day.
In his diet plan he cannot eat on for three consecutive days. But Kapil is very fond of eating , so he decided to take as much as calorie despite remembering the fact that he cannot eat on three consecutive days. Help him in finding amount of calorie he could take.

 

Input:
The first line will contain an integer T denoting the no of  test cases.Each test case contains 2 lines.The first line of each test case will contain an integer n i.e number of days. In the next line are n space separated values of ai indicating the intake of calorie per day.

Output:
Print the maximum amount of calorie, Kapil can take in a new line .

Constraints:

1<=T<=25
1<=n<=100000
1<=ai<=100000


Example:

Input                
2                   
5                    
3 2 1 10 3
8
3 2 3 2 3 5 1 3 

Output
18
17


Explanation:

(i)In first case he will eat on 1st,2nd,4th and 5th day (3+2+10+3)=18
(ii)Similarly in second case, (3+3+3+5+3)=17

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: vaibhav garg
Author: justrelax


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.