Stickler the thief wants to loot money from a society** **having** n** houses in a single line. He is a weird person and follows a certain **rule **when looting the houses. According to the rule, he will **never loot two consecutive houses**. At the same time, he wants to **maximize **the amount he **loots**. The thief knows which house has what amount of money but is unable to come up with an optimal looting strategy. He asks for your help to **find the maximum money he can get** if he strictly **follows **the **rule**. Each house has **a[i]**** amount of money** present in it.

**Input:**

The first line of input contains an integer T denoting the number of test cases. T testcases follow. Each test case contains an integer **n** which denotes the number of houses. Next line contains space separated numbers denoting the amount of money in each house.

**Output:**

For each testcase, in a newline, print an integer which denotes the maximum amount he can take home.

**Constraints:**

1 <= T <= 200

1 <= n <= 10^{4}

1 <= a[i] <= 10^{4}

**Example:
Input:**

2

6

5 5 10 100 10 5

3

1 2 3

110

4

**Explanation:
Testcase1:**

5+100+5=110

1+3=4

Author: shashwat jain

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.

msriramvarma01 | 25 |

AbhilashKumar2 | 24 |

monusinghal | 24 |

tripurari_IT | 24 |

Abreez Das | 23 |

ARUN_PUNDIR | 609 |

manishgupta8497 | 607 |

KhyatiSoneji | 501 |

Abhimanyu_kumar | 487 |

vvggfggcg | 453 |

blackshadows | 5333 |

Ibrahim Nash | 5221 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.