Given an array a consisting of N non-negative numbers your task is to find the minimum sum of the array such that out of 3 consecutive elements you need to add at-least one.
First line consists of T Test cases. Each test case contains 2 lines . The first line consists of a number N specifying the number of elements in an array and the next line contains N space separated elements.
Output in a single line minimum sum that can be obtained.
1 2 3 6 7 1
Moving from left to right 3+1. When 3 is added next 3 consecutive elements be 6 7 and 1, from which we take 1. Which covers all subarray of lenght 3 (3+1=4).
We won't take any element as the array length is less than 3.
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.