Maximise sum

Company: Google_8nov

Difficulty: medium