Problem list
Log in
#coci00184 · COCI 2010/2011 Contest 6

Abeceda

Platinum IV 1.0 s 32 MB

Mirko has developed his own video game. The game has N levels and each successfully completed level is worth a certain number of points, which add up to the player’s total score on an online rank list of all players. Mirko has ordered his levels by difficulty from the easiest to the most difficult, but he has made a mistake and made some difficult levels worth less points than some of the easier ones. To overcome this problem, Mirko has decided to reduce the number of points for certain levels with the goal of making the point sequence strictly increasing (so in the end easier levels are worth less points than the difficult ones). Help Mirko fix his video game in such a way that the total number of points reduced is minimal. Final points have to be positive. You can assume that a solution exists for each test case.

Input

The first line of input contains a positive integer $N$ ($N \le 100$), the number of words.

The following $N$ lines contain the list of words found, one word per line. Each word consists of at most $10$ lowercase letters.

Output

The first and and only line of output should contain one number - the minimum total number of points Mirko has to subtract to fulfill requirements given in the task statement above.

Example 1

Input
5
ula
uka
klua
kula
al
Output
luka

Example 2

Input
4
jaja
baba
baja
beba
Output
!

Example 3

Input
3
marko
darko
zarko
Output
?
Source
COCI 2010/2011 Contest 6
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code