I can't work around how to select the elements.
for example if we have 1,2,3,4,5,6,7,8,9,10
and we choose 4,5
then we cant choose 6,7,8 but we can choose 9th
So, I guess in general
If we choose 2 consecutive elements arr[i] and arr[i+1],
then we CANNOT choose from next 3 values arr[i+2], arr[i+3], arr[i+4] and we may only choose from arr[i+5]
for ex:
Consider this array with 9 elements
Input: arr[] = {100, 200, 100, 500, 900, 500, 300, 400, 100}
Output: 1500
Maximum sum for this should be: 1500
Which is obtained by taking the values at places 4, 5 and 9
i.e 500+900+100 = 1500
Another example:
Consider this array with 10 elements
Input: arr[] = {500, 700, 300, 500, 900, 700, 600, 400, 700, 500}
Output: 2800
select elements at (2, 5, 9, 10)
i.e 700+900+700+500 = 2800