There is the obvious conclusion that choosing R ones is equivalent to choosing N-R ones, due to the fact that there is no essential difference between red and blue. This allows us to guarantee R\le\frac N2.
At this point, there is a greedy conclusion that the red lattice is not continuous. This can be proved by the adjustment method, for example, if the colouring is \{\tt B,R,R,B,B\}, the gain at this point is A_1+A_3. And if adjusted to \{\tt B,R,B,R,R,B\}, the gain at this point is A_1+A_2+A_3+A_4, which is significantly better.
Thus, the problem is transformed into, pick R discontinuous positions, pick the i-th position with contribution A_i+A_{i-1}, and find the maximum contribution. That is, the classical problem of contrite greed P1484 Planting Trees.