{"problem":{"name":"E. Lust","description":{"content":"_A false witness that speaketh lies!_ You are given a sequence containing _n_ integers. There is a variable _res_ that is equal to 0 initially. The following process repeats _k_ times. Choose an ind","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF891E"},"statements":[{"statement_type":"Markdown","content":"_A false witness that speaketh lies!_\n\nYou are given a sequence containing _n_ integers. There is a variable _res_ that is equal to 0 initially. The following process repeats _k_ times.\n\nChoose an index from 1 to _n_ uniformly at random. Name it _x_. Add to _res_ the multiply of all _a__i_'s such that 1 ≤ _i_ ≤ _n_, but _i_ ≠ _x_. Then, subtract _a__x_ by 1.\n\nYou have to find expected value of _res_ at the end of the process. It can be proved that the expected value of _res_ can be represented as an irreducible fraction . You have to find .\n\n## Input\n\nThe first line contains two integers _n_ and _k_ (1 ≤ _n_ ≤ 5000, 1 ≤ _k_ ≤ 109) — the number of elements and parameter _k_ that is specified in the statement.\n\nThe second line contains _n_ space separated integers _a_1, _a_2, ..., _a__n_ (0 ≤ _a__i_ ≤ 109).\n\n## Output\n\nOutput a single integer — the value .\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"_A false witness that speaketh lies!_\n\n给定一个包含 #cf_span[n] 个整数的序列。初始时有一个变量 #cf_span[res] 等于 #cf_span[0]。该过程重复 #cf_span[k] 次。\n\n在 #cf_span[1] 到 #cf_span[n] 中均匀随机选择一个索引，记为 #cf_span[x]。将所有满足 #cf_span[1 ≤ i ≤ n] 且 #cf_span[i ≠ x] 的 #cf_span[ai] 的乘积加到 #cf_span[res] 上。然后，将 #cf_span[ax] 减去 #cf_span[1]。\n\n你需要求出该过程结束后 #cf_span[res] 的期望值。可以证明，#cf_span[res] 的期望值可以表示为一个既约分数 。你需要求出 。\n\n第一行包含两个整数 #cf_span[n] 和 #cf_span[k] (#cf_span[1 ≤ n ≤ 5000], #cf_span[1 ≤ k ≤ 109]) —— 元素个数和题目中指定的参数 #cf_span[k]。\n\n第二行包含 #cf_span[n] 个空格分隔的整数 #cf_span[a1, a2, ..., an] (#cf_span[0 ≤ ai ≤ 109])。\n\n输出一个整数 —— 的值。\n\n## Input\n\n第一行包含两个整数 #cf_span[n] 和 #cf_span[k] (#cf_span[1 ≤ n ≤ 5000], #cf_span[1 ≤ k ≤ 109]) —— 元素个数和题目中指定的参数 #cf_span[k]。第二行包含 #cf_span[n] 个空格分隔的整数 #cf_span[a1, a2, ..., an] (#cf_span[0 ≤ ai ≤ 109])。\n\n## Output\n\n输出一个整数 —— 的值。\n\n[samples]","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n, k \\in \\mathbb{Z}^+ $ with $ 1 \\leq n \\leq 5000 $, $ 1 \\leq k \\leq 10^9 $.  \nLet $ \\mathbf{a} = (a_1, a_2, \\dots, a_n) \\in \\mathbb{Z}_{\\geq 0}^n $ be the initial sequence.  \nLet $ R $ be the random variable denoting the final value of `res` after $ k $ iterations.  \n\n**Process**  \nAt each iteration:  \n- Choose index $ x \\in \\{1, \\dots, n\\} $ uniformly at random.  \n- Add to `res` the value $ \\prod_{\\substack{i=1 \\\\ i \\neq x}}^n a_i $.  \n- Decrement $ a_x \\leftarrow a_x - 1 $.  \n\n**Objective**  \nCompute $ \\mathbb{E}[R] \\mod (10^9 + 7) $, where $ \\mathbb{E}[R] = \\frac{p}{q} $ is the expected value in irreducible form, and output $ p \\cdot q^{-1} \\mod (10^9 + 7) $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF891E","tags":["combinatorics","math","matrices"],"sample_group":[["2 1\n5 5","5"],["1 10\n80","10"],["2 2\n0 0","500000003"],["9 4\n0 11 12 9 20 7 8 18 2","169316356"]],"created_at":"2026-03-03 11:00:39"}}