{"raw_statement":[{"iden":"statement","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 ."},{"iden":"input","content":"The 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)."},{"iden":"output","content":"Output a single integer — the value ."},{"iden":"examples","content":"Input\n\n2 1\n5 5\n\nOutput\n\n5\n\nInput\n\n1 10\n80\n\nOutput\n\n10\n\nInput\n\n2 2\n0 0\n\nOutput\n\n500000003\n\nInput\n\n9 4\n0 11 12 9 20 7 8 18 2\n\nOutput\n\n169316356"}],"translated_statement":[{"iden":"statement","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输出一个整数 —— 的值。"},{"iden":"input","content":"第一行包含两个整数 #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])。"},{"iden":"output","content":"输出一个整数 —— 的值。"},{"iden":"examples","content":"输入\n2 1\n5 5\n输出\n5\n\n输入\n1 10\n8\n输出\n10\n\n输入\n2 2\n0 0\n输出\n500000003\n\n输入\n9 4\n0 11 12 9 20 7 8 18 2\n输出\n169316356"}],"sample_group":[],"show_order":[],"formal_statement":"**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) $.","simple_statement":null,"has_page_source":false}