{"raw_statement":[{"iden":"statement","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"},{"iden":"input","content":"The 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). "},{"iden":"output","content":"Print one number, the maximum number of nodes Ivan can draw. It is guaranteed that the answer fits on a 63-bits integer."},{"iden":"note","content":"The number of levels of the tree (except for the root) is the same as the number of elements in the array"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**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$$","simple_statement":"Given an array A of length n, where each element A[i] represents the number of children at level i, find the maximum number of nodes in a rooted tree, starting from the root. The root is level 0, and each level i has exactly A[i] children per node.","has_page_source":false}