{"problem":{"name":"E. Colored Balls","description":{"content":"There are _n_ boxes with colored balls on the table. Colors are numbered from 1 to _n_. _i_\\-th box contains _a__i_ balls, all of which have color _i_. You have to write a program that will divide all","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF792E"},"statements":[{"statement_type":"Markdown","content":"There are _n_ boxes with colored balls on the table. Colors are numbered from 1 to _n_. _i_\\-th box contains _a__i_ balls, all of which have color _i_. You have to write a program that will divide all balls into sets such that:\n\n*   each ball belongs to exactly one of the sets,\n*   there are no empty sets,\n*   there is no set containing two (or more) balls of different colors (each set contains only balls of one color),\n*   there are no two sets such that the difference between their sizes is greater than 1.\n\nPrint the minimum possible number of sets.\n\n## Input\n\nThe first line contains one integer number _n_ (1 ≤ _n_ ≤ 500).\n\nThe second line contains _n_ integer numbers _a_1, _a_2, ... , _a__n_ (1 ≤ _a__i_ ≤ 109).\n\n## Output\n\nPrint one integer number — the minimum possible number of sets.\n\n[samples]\n\n## Note\n\nIn the first example the balls can be divided into sets like that: one set with 4 balls of the first color, two sets with 3 and 4 balls, respectively, of the second color, and two sets with 4 balls of the third color.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"桌上有 #cf_span[n] 个装有彩球的盒子。颜色编号从 #cf_span[1] 到 #cf_span[n]。第 #cf_span[i] 个盒子包含 #cf_span[ai] 个球，所有球的颜色均为 #cf_span[i]。你需要编写一个程序，将所有球划分为若干集合，使得：\n\n请输出可能的最少集合数量。\n\n第一行包含一个整数 #cf_span[n]（#cf_span[1 ≤ n ≤ 500]）。\n\n第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ... , an]（#cf_span[1 ≤ ai ≤ 109]）。\n\n请输出一个整数 —— 可能的最少集合数量。\n\n在第一个例子中，球可以被划分为如下集合：一个包含 #cf_span[4] 个第一种颜色球的集合，两个分别包含 #cf_span[3] 和 #cf_span[4] 个第二种颜色球的集合，以及两个各包含 #cf_span[4] 个第三种颜色球的集合。\n\n## Input\n\n第一行包含一个整数 #cf_span[n]（#cf_span[1 ≤ n ≤ 500]）。第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ... , an]（#cf_span[1 ≤ ai ≤ 109]）。\n\n## Output\n\n请输出一个整数 —— 可能的最少集合数量。\n\n[samples]\n\n## Note\n\n在第一个例子中，球可以被划分为如下集合：一个包含 #cf_span[4] 个第一种颜色球的集合，两个分别包含 #cf_span[3] 和 #cf_span[4] 个第二种颜色球的集合，以及两个各包含 #cf_span[4] 个第三种颜色球的集合。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of colors.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of positive integers, where $ a_i $ is the number of balls of color $ i $.\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 500 $  \n2. $ 1 \\leq a_i \\leq 10^9 $ for all $ i \\in \\{1, \\dots, n\\} $\n\n**Objective**  \nFind the minimum number of sets $ k \\in \\mathbb{Z}^+ $ such that the balls can be partitioned into $ k $ sets, where in each set, no two balls have the same color (i.e., each set contains at most one ball of each color).","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF792E","tags":["greedy","math","number theory"],"sample_group":[["3\n4 7 8","5"],["2\n2 7","4"]],"created_at":"2026-03-03 11:00:39"}}