Firstly divide the sequence into sub-sequences(of consecutive elements) according to whether parity is changing or remaining same.For example consider sequence:1,2,3,4,6,8,4,2,9,6,3 than the subsequence are:

1)1,2,3

2)4,6,8,4,2

3)9,6,3

Now all elements of 1 and 3(i.e. of changing parity) can be taken as they pose no problem for selecting any other number.

Now the question comes down to selecting non-consecutive elements from a sequence like 2) and having maximum sum.Let a1,a2..an be the sequence now suppose than a1 and a2 are both not present in the final subsequence. But then we can increase the sum by taking a1 leading to contradiction as we assumed that our subsequence had maximum sum.Hence the final subsequence must contain a1 or a2.

let l(1,n) represent the sequence a1,a2..an then maxsum(l(1,n))=max(a1+maxsum(l(3,n)),a2+maxsum(l(4,n))) where memoization is applied on maxsum(l(x,n))