Олимпиадный тренинг

Задача 43517. Autumn Festival


In kindergarten, the Sun for the Autumn Festival, all children should have the same number of balloons. The teacher Anna Nikolaevna found out how many balloons each child can bring from home for the holiday. & nbsp; To equalize the number of balloons for all children, the parent committee decided to purchase the required number of balloons.

In total, in the group of Anna Nikolaevna n pupils, the number of available balloons for each child is ai.< /p>

You are the treasurer of the parent committee, which needs to calculate the minimum number of balloons that must be purchased in order to equalize their number for each child.

We will assume that the balloons that the children have will not burst until the end of the holiday.

 

Input data

The first line of the input contains an integer n (1 <= n <= 100) — the number of pupils in Anna Nikolaevna's group.

The second line contains n numbers a1,a2< /code>, ..., an, where ai  (0 <= ai <= 106) &mdash ; the number of balloons that the ith child can bring from home.

 

Imprint

Into a single line of output print an integer — the minimum number of balloons that you need to purchase.

 
Examples
# Input Output
1 5
0 1 2 3 4
10
2 5
1 1 0 1 1
1
3 3
1 3 1
4
4 1
12
0

Запрещенные операторы:max;sum