cho.sh
NotesCho Mini
Loading...

Climbing Stairs

Time limit

1s

Memory limit

128 MB

Problem

The stair-climbing game starts below the stairs and ends at the final stair at the top. Each stair has a score written on it, and stepping on that stair earns that score.

For instance, if you step on the 1st, 2nd, 4th, and 6th stairs as in <Figure 2>, the total score is 10 + 20 + 25 + 20 = 75.

You must follow these rules when climbing.

  1. You may climb either one stair or two stairs at a time. In other words, from a stair you stepped on, you may move to the next stair or the stair after that.
  2. You may not step on three consecutive stairs. The starting point is not counted as a stair.
  3. You must step on the final stair.

Therefore, after stepping on the 1st stair, you may move to the 2nd or 3rd stair. You cannot move directly from the 1st stair to the 4th stair, and you cannot step on the 1st, 2nd, and 3rd stairs all consecutively.

Given the scores written on the stairs, compute the maximum total score you can obtain.

Input

The first line contains the number of stairs N.

Starting from the second line, N lines follow. Each line contains the score written on one stair, in order from the bottom stair to the top stair. N is a positive integer at most 300, and each score is a positive integer at most 10,000.

Output

Print the maximum total score obtainable while following the rules and stepping on the final stair.