AtCoder Regular Contest 130
F
Replace by Average
AtCoder
⌀ 3211
原题
← E→
翻译中…

Problem Statement

翻译中…

Given is a sequence of $N$ positive integers $A = (A_1, A_2, \ldots, A_N)$.

翻译中…

You can do the following operation on this sequence any number of times.

翻译中…
  • Choose integers $i, j, k$ such that $1\leq i < j < k \leq N$ and $j = \frac{i+k}{2}$. Replace $A_j$ with $\lfloor\frac{A_i+A_k}{2}\rfloor$.
翻译中…

Find the minimum possible value of $\sum_{i=1}^N A_i$ after the operations.

翻译中…

Constraints

翻译中…
  • $3\leq N\leq 3\times 10^5$
  • $1\leq A_i\leq 10^{12}$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \ldots A_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
5
2 2 5 5 4
Output #1
13
The following operations achieves $\sum_{i=1}^N A_i = 13$. - Do the operation with $(i,j,k) = (1,3,5)$. The sequence $A$ is now $(2,2,3,5,4)$. - Do the operation with $(i,j,k) = (3,4,5)$. The sequence $A$ is now $(2,2,3,3,4)$. - Do the operation with $(i,j,k) = (2,3,4)$. The sequence $A$ is now $(2,2,2,3,4)$.
Input #2
5
3 1 4 1 5
Output #2
11
Input #3
3
3 1 3
Output #3
7
Input #4
3
3 5 3
Output #4
9
题目信息
题号
arc130_f
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。