#### Start

2019-11-26 20:00 AKST

## Problem Set 1

#### End

2019-12-03 20:00 AKST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -254 days 10:49:37

168:00:00

0:00:00

# Problem CNikola

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:

• If the jump is in the forward direction, it must be one square longer than the preceding jump.

• If the jump is in the backward direction, it must be exactly the same length as the preceding jump.

For example, after the first jump (when on square 2), Nikola can jump back to square 1 or forwards to square 4. For instance, if $N = 6$ (see first example case below), one possible way to reach $N$ would be by using the squares 1-2-1-3-6.

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$.

## Input

The first line contains the integer $N$, $2 \le N \le 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

Output the smallest total cost for Nikola to get to square $N$.

Sample Input 1 Sample Output 1
6
1
2
3
4
5
6

12

Sample Input 2 Sample Output 2
8
2
3
4
3
1
6
1
4

14
{"ft_lang_label":"__label__en","ft_lang_prob":0.90642416,"math_prob":0.99716157,"size":1385,"snap":"2020-34-2020-40","text_gpt3_token_len":379,"char_repetition_ratio":0.15423606,"word_repetition_ratio":0.06666667,"special_character_ratio":0.29025272,"punctuation_ratio":0.09240924,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9942525,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-07T15:49:37Z\",\"WARC-Record-ID\":\"<urn:uuid:ec56b0b5-6666-48ed-832b-8c6e81bf1b7a>\",\"Content-Length\":\"19755\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f1f72a3a-7080-4cf0-b58a-a92e28391ec4>\",\"WARC-Concurrent-To\":\"<urn:uuid:72cb1986-d5fa-4f46-bd48-123366bab2e5>\",\"WARC-IP-Address\":\"104.26.13.234\",\"WARC-Target-URI\":\"https://open.kattis.com/contests/cajcmm/problems/nikola\",\"WARC-Payload-Digest\":\"sha1:5NPYL3TP2WHMCKSU7EU7UR53SOQFNG3V\",\"WARC-Block-Digest\":\"sha1:5SS3IY3QQP6ZOFSYLN7MJFN4K46F4KHU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439737204.32_warc_CC-MAIN-20200807143225-20200807173225-00423.warc.gz\"}"}