Given an array of integers, check whether there is a subsequence with odd sum and if yes, then finding the maximum odd sum. If no subsequence contains odd sum, print -1.

**Input:**

First line of input contains a single integer **T** which denotes the number of test cases. Then **T** test cases follows. First line of each test case contains a single integer **N** which denotes the number of elements in the array. Second line of each test case contains **N** space separated integers.

**Output:**

For each test case print the maximum odd sum that can be obtained from any subsequence of the given array. If no subsequence contains odd sum, print -1.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{4}

1 <= A[i] <= 10^{5}

**Example:**

**Input:**

3

5

2 5 -4 3 -1

4

4 -3 3 -5

3

2 4 6

**Output:**

9

7

-1

Author: harsh.agarwal0

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.

VivSisMMM | 164 |

d_Coder00 | 163 |

ajayjadhav35 | 153 |

Astikeysingh | 148 |

Sathvik Avasarala | 143 |

Pulkit__Sharma__ | 658 |

Anirban166 | 565 |

abducodes | 542 |

Sathvik Avasarala | 506 |

Found_me | 494 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.