{"raw_statement":[{"iden":"statement","content":"Polycarp has array of N integers a1, ..., aN. Polycarp makes experiments, he applies specific commands. There are M commands of three types. First one follows the form: _1 L R_, it means we should decrease by 1 the numbers from array with indexes L, ..., R. Second one follows the form: _2 L R_, it means we should increase by 1 the numbers from array with indexes L, ..., R. Third one follows the form: _3 L R a0 a1 a2 a3 a4_, it means we should compute , for f(xi) = a0·xi4 + a1·xi3 + a2·xi2 + a3·xi1 + a4 and xi is number form array with index i. You should execute all given commands.\n\nIt is garantied that numbers in array always lesser than 201 and greater than  - 201, and any sums from  - 1018 to 1018.\n\nThe first line contains integer N — the number of integers in array (1 ≤ N ≤ 105). The first line contains a1, ..., aN — initial numbers in array. The third line contains integer M — the number of commands (1 ≤ M ≤ 105). M lines follow, each containing description of commands. Format is decribed above. 1 ≤ L ≤ R ≤ N,  - 100 ≤ a0, a1, a2, a3, a4 ≤ 100.\n\nOutput result for each commands of third type in separated lines.\n\n"},{"iden":"input","content":"The first line contains integer N — the number of integers in array (1 ≤ N ≤ 105). The first line contains a1, ..., aN — initial numbers in array. The third line contains integer M — the number of commands (1 ≤ M ≤ 105). M lines follow, each containing description of commands. Format is decribed above. 1 ≤ L ≤ R ≤ N,  - 100 ≤ a0, a1, a2, a3, a4 ≤ 100."},{"iden":"output","content":"Output result for each commands of third type in separated lines."},{"iden":"examples","content":"Input51 2 3 4 573 1 5 0 0 0 0 13 1 5 0 0 0 1 03 1 5 0 0 1 0 03 1 5 0 1 0 0 03 1 5 1 0 0 0 01 1 53 1 5 1 0 0 0 0Output51555225979354Input51 2 3 4 551 1 51 1 51 1 53 1 5 0 1 0 1 03 1 5 1 0 1 0 5Output069"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ N \\in \\mathbb{Z}^+ $ be the length of the array.  \nLet $ A = (a_1, a_2, \\dots, a_N) \\in \\mathbb{Z}^N $ be the initial array.  \nLet $ M \\in \\mathbb{Z}^+ $ be the number of commands.  \nLet $ \\mathcal{C} = \\{C_1, \\dots, C_M\\} $ be the sequence of commands, where each $ C_j $ is one of:  \n- Type 1: $ (1, L, R) $ — decrement $ a_i \\leftarrow a_i - 1 $ for all $ i \\in [L, R] $,  \n- Type 2: $ (2, L, R) $ — increment $ a_i \\leftarrow a_i + 1 $ for all $ i \\in [L, R] $,  \n- Type 3: $ (3, L, R, a_0, a_1, a_2, a_3, a_4) $ — compute $ \\sum_{i=L}^{R} f(a_i) $, where $ f(x) = a_0 x^4 + a_1 x^3 + a_2 x^2 + a_3 x + a_4 $.  \n\n**Constraints**  \n1. $ 1 \\le N \\le 10^5 $  \n2. $ 1 \\le M \\le 10^5 $  \n3. For all $ i \\in \\{1, \\dots, N\\} $: $ -201 < a_i < 201 $  \n4. For all commands of Type 3: $ -100 \\le a_0, a_1, a_2, a_3, a_4 \\le 100 $  \n5. For all commands: $ 1 \\le L \\le R \\le N $  \n6. All intermediate sums lie in $ [-10^{18}, 10^{18}] $  \n\n**Objective**  \nFor each command $ C_j $ of Type 3, output:  \n$$\n\\sum_{i=L}^{R} \\left( a_0 a_i^4 + a_1 a_i^3 + a_2 a_i^2 + a_3 a_i + a_4 \\right)\n$$","simple_statement":"You are given an array of N integers and M commands. Three types of commands:\n\n1. `1 L R` — subtract 1 from all elements from index L to R.\n2. `2 L R` — add 1 to all elements from index L to R.\n3. `3 L R a0 a1 a2 a3 a4` — for each element x in the subarray [L, R], compute f(x) = a0·x⁴ + a1·x³ + a2·x² + a3·x + a4, and output the sum of all f(x) values.\n\nExecute all commands and print the result for each type-3 command on a separate line.","has_page_source":false}