{"raw_statement":[{"iden":"statement","content":"In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury.\n\nTotally in Berland there are _n_ citizens, the welfare of each of them is estimated as the integer in _a__i_ burles (burle is the currency in Berland).\n\nYou are the royal treasurer, which needs to count the minimum charges of the kingdom on the king's present. The king can only give money, he hasn't a power to take away them."},{"iden":"input","content":"The first line contains the integer _n_ (1 ≤ _n_ ≤ 100) — the number of citizens in the kingdom.\n\nThe second line contains _n_ integers _a_1, _a_2, ..., _a__n_, where _a__i_ (0 ≤ _a__i_ ≤ 106) — the welfare of the _i_\\-th citizen."},{"iden":"output","content":"In the only line print the integer _S_ — the minimum number of burles which are had to spend."},{"iden":"examples","content":"Input\n\n5\n0 1 2 3 4\n\nOutput\n\n10\n\nInput\n\n5\n1 1 0 1 1\n\nOutput\n\n1\n\nInput\n\n3\n1 3 1\n\nOutput\n\n4\n\nInput\n\n1\n12\n\nOutput\n\n0"},{"iden":"note","content":"In the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.\n\nIn the second example it is enough to give one burle to the third citizen.\n\nIn the third example it is necessary to give two burles to the first and the third citizens to make the welfare of citizens equal 3.\n\nIn the fourth example it is possible to give nothing to everyone because all citizens have 12 burles."}],"translated_statement":[{"iden":"statement","content":"在伯兰，今天是平等节。为了庆祝这个节日，国王决定通过国家金库的支出，使所有公民的福利均等化。\n\n伯兰共有 #cf_span[n] 名公民，每个人的福利被评估为一个整数 #cf_span[ai] 布尔（布尔是伯兰的货币）。\n\n你是皇家财政官，需要计算国王赠礼所需的最少开支。国王只能给钱，没有权力收回钱。\n\n第一行包含整数 #cf_span[n]（#cf_span[1 ≤ n ≤ 100]）——王国中公民的数量。\n\n第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ..., an]，其中 #cf_span[ai]（#cf_span[0 ≤ ai ≤ 106]）——第 #cf_span[i] 位公民的福利。\n\n仅在一行中输出整数 #cf_span[S]——需要花费的最少布尔数。\n\n在第一个例子中，如果我们给第一位公民增加 #cf_span[4] 布尔，第二位增加 #cf_span[3]，第三位增加 #cf_span[2]，第四位增加 #cf_span[1]，则所有公民的福利都将等于 #cf_span[4]。\n\n在第二个例子中，只需给第三位公民一布尔即可。\n\n在第三个例子中，必须给第一位和第三位公民各两布尔，使所有公民的福利等于 #cf_span[3]。\n\n在第四个例子中，无需给任何人任何钱，因为所有公民都有 #cf_span[12] 布尔。"},{"iden":"input","content":"第一行包含整数 #cf_span[n]（#cf_span[1 ≤ n ≤ 100]）——王国中公民的数量。第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ..., an]，其中 #cf_span[ai]（#cf_span[0 ≤ ai ≤ 106]）——第 #cf_span[i] 位公民的福利。"},{"iden":"output","content":"仅在一行中输出整数 #cf_span[S]——需要花费的最少布尔数。"},{"iden":"examples","content":"输入\n5\n0 1 2 3 4\n输出\n10\n\n输入\n5\n1 1 0 1 1\n输出\n1\n\n输入\n3\n1 3 1\n输出\n4\n\n输入\n1\n12\n输出\n0"},{"iden":"note","content":"在第一个例子中，如果我们给第一位公民增加 #cf_span[4] 布尔，第二位增加 #cf_span[3]，第三位增加 #cf_span[2]，第四位增加 #cf_span[1]，则所有公民的福利都将等于 #cf_span[4]。在第二个例子中，只需给第三位公民一布尔即可。在第三个例子中，必须给第一位和第三位公民各两布尔，使所有公民的福利等于 #cf_span[3]。在第四个例子中，无需给任何人任何钱，因为所有公民都有 #cf_span[12] 布尔。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of citizens.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of non-negative integers representing the welfare of each citizen.\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 100 $  \n2. $ 0 \\leq a_i \\leq 10^6 $ for all $ i \\in \\{1, \\dots, n\\} $\n\n**Objective**  \nFind the minimum total amount of money to distribute (only additions allowed) so that all citizens have equal welfare. This minimum is:  \n$$\nS = n \\cdot \\max(A) - \\sum_{i=1}^{n} a_i\n$$","simple_statement":null,"has_page_source":false}