#C3849. Maximizing Sequence Sum with Skipping Rules

    ID: 47321 Type: Default 1000ms 256MiB

Maximizing Sequence Sum with Skipping Rules

Maximizing Sequence Sum with Skipping Rules

You are given a sequence of N integers. Your task is to select a subset of these integers so that their sum is maximized, following these rules:

  • If you choose an element at index i, you cannot choose the elements at indices i+1 and i+2.
  • You are allowed to select non-adjacent elements as long as the above condition is maintained.

If it is not possible to obtain a positive sum by following the rules, output kusoge.

Note: The indices are 0-based.

inputFormat

The input is read from stdin and consists of two lines:

  1. The first line contains an integer n (the number of elements in the sequence).
  2. The second line contains n space-separated integers representing the sequence.

outputFormat

Output a single line to stdout: the maximum sum that can be obtained by selecting elements according to the rules. If no positive sum can be achieved, output kusoge (without quotes).

## sample
5
3 2 5 10 7
15