logo AlgoBeat OnlineJudge
登录 注册

#217681. [ECNA 2023] Double Up

内存限制:2048 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

A Double Up game consists of a sequence of numbers , where each is a power of two. In one move one can either remove one of the numbers, or merge two identical adjacent numbers into a single number of twice the value. For example, for sequence , we can merge the s and obtain , then merge the s and obtain , then remove the , and, finally, merge the s, obtaining a single final number, . We play the game until a single number remains. What is the largest number we can obtain?

输入格式

The input consists of two lines. The first line contains (). The second line contains numbers , where for each .

输出格式

The output consists of a single line containing the largest number that can be obtained from the input sequence .

样例

样例输入 1

5
4 2 2 1 8

样例输出 1

16