{"problem":{"name":"B. Maximum Tree","description":{"content":"Ivan is a new professor of the University of Nice Algebra Lovers (UNAL), he is going to give a data structures course, that's why he is preparing his slides and wants to draw a beautiful rooted tree. ","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10146B"},"statements":[{"statement_type":"Markdown","content":"Ivan is a new professor of the University of Nice Algebra Lovers (UNAL), he is going to give a data structures course, that's why he is preparing his slides and wants to draw a beautiful rooted tree. As he loves math, he has a very special array of numbers A and he wants to use each element of the array as the number of children for some level in the tree. For example, if A = [2, 1, 3] two of the possible trees he could draw are the following:\n\nIvan wants to draw a rooted tree that has the maximum number of nodes. As he is busy with LaTeX he wants you to write a program that computes such number.\n\nThe first line consists of an integer n (1 ≤ n ≤ 32), the next line contains n numbers separated by a single space, the elements of A (1 ≤ Ai ≤ 10). \n\nPrint one number, the maximum number of nodes Ivan can draw. It is guaranteed that the answer fits on a 63-bits integer.\n\nThe number of levels of the tree (except for the root) is the same as the number of elements in the array\n\n## Input\n\nThe first line consists of an integer n (1 ≤ n ≤ 32), the next line contains n numbers separated by a single space, the elements of A (1 ≤ Ai ≤ 10). \n\n## Output\n\nPrint one number, the maximum number of nodes Ivan can draw. It is guaranteed that the answer fits on a 63-bits integer.\n\n[samples]\n\n## Note\n\nThe number of levels of the tree (except for the root) is the same as the number of elements in the array","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of levels (excluding the root).  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of positive integers, where $ a_i $ denotes the number of children per node at level $ i $.\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 32 $  \n2. $ 1 \\leq a_i \\leq 10 $ for all $ i \\in \\{1, \\dots, n\\} $\n\n**Objective**  \nCompute the maximum number of nodes in a rooted tree where:  \n- The root is at level 0.  \n- Each node at level $ i-1 $ has exactly $ a_i $ children (for $ i = 1, \\dots, n $).  \n\nThe total number of nodes is:  \n$$\n1 + \\sum_{i=1}^{n} \\prod_{j=1}^{i} a_j\n$$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10146B","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}