{"trustable":false,"sections":[{"title":"Description","value":{"format":"MD","content":"给定一个长度为 $N$ 的数列 $a_1,\\ a_2,\\ \\dots , a_N$ ,你可以任意次进行如下操作:\n\n- 选择数列中两个相邻且相等的元素。删去其中一个元素并使另一个元素的值 $+1$ 。\n\n问在最优策略下,数次操作后数列中的最大值可以是多少。\n"}},{"title":"Input","value":{"format":"MD","content":"输入第一行包含一个整数 $N (1 \\le N \\le 248)$ 表示数列最初的长度;\n\n接下来 $N$ 行每行一个数字 $a_1 \\dots a_N (0 \\le a_i \\le 40)$ 表示数列中的元素。\n"}},{"title":"Output","value":{"format":"MD","content":"Please output the largest integer Bessie can generate.\n"}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n1\n1\n1\n2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"MD","content":"In this example shown here, Bessie first merges the second and third 1s to\n\nobtain the sequence 1 2 2, and then she merges the 2s into a 3. Note that it is\n\nnot optimal to join the first two 1s.\n"}}]}