#P9280. [AGM 2023 资格赛] Monty Hall

[AGM 2023 资格赛] Monty Hall

Problem Description

Monty Hall is a game show host. One day, he decided to introduce a new game.

There are a total of nn doors arranged in a circle. The player is initially standing in front of door 11. In each round, the player performs the following operations: choose an integer ii, pay a cost of CiC_i to move ii steps to the right, and then the player opens the door at their current position. In particular, it is guaranteed that CiCi+1(1i<n)C_i\geq C_{i+1}(1\leq i<n).

The player wants to know the minimum total cost needed to open all doors.

Input Format

The first line contains an integer N(1N105)N(1\leq N\leq 10^5).

The next line contains NN integers Ci(1Ci105)C_i(1\leq C_i\leq 10^5).

Output Format

One integer, representing the answer.

5
4 3 3 3 3

15

Hint

Translated by ChatGPT 5