|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||128 MB||7||5||5||83.333%|
Against his own will, Nikola has become the main character in a game. The game is played on a row of N squares, numbered 1 to N. Nikola is initially in square 1 and can jump to other squares. Nikola's first jump must be to square 2. Each subsequent jump must satisfy two constraints:
For example, after the first jump (when on square 2), Nikola can jump back to square 1 or forwards to square 4.
Every time he enters a square, Nikola must pay an entry fee. Nikola's goal is to get from square 1 to square N as cheaply as possible. Write a program that determines the smallest total cost for Nikola to get to square N.
The first line contains the integer N, 2 ≤ N ≤ 1000, the number of squares.
Each of the following N lines contains the entry fee for one square, a positive integer less than 500. The entry fees will be given in order for squares 1 to N.
Output the smallest total cost for Nikola to get to square N.
6 1 2 3 4 5 6