The Fair Nut lives in $n$ story house. $a_i$ people live on the $i$-th floor of the house. Every person uses elevator twice a day: to get from the floor where he/she lives to the ground (first) floor and to get from the first floor to the floor where he/she lives, when he/she comes back home in the evening. 

It was decided that elevator, when it is not used, will stay on the $x$-th floor, but $x$ hasn't been chosen yet. When a person needs to get from floor $a$ to floor $b$, elevator follows the simple algorithm:   Moves from the $x$-th floor (initially it stays on the $x$-th floor) to the $a$-th and takes the passenger.  Moves from the $a$-th floor to the $b$-th floor and lets out the passenger (if $a$ equals $b$, elevator just opens and closes the doors, but still comes to the floor from the $x$-th floor).  Moves from the $b$-th floor back to the $x$-th.  The elevator never transposes more than one person and always goes back to the floor $x$ before transposing a next passenger. The elevator spends one unit of electricity to move between neighboring floors. So moving from the $a$-th floor to the $b$-th floor requires $|a - b|$ units of electricity.

Your task is to help Nut to find the minimum number of electricity units, that it would be enough for one day, by choosing an optimal the $x$-th floor. Don't forget than elevator initially stays on the $x$-th floor. 


-----Input-----

The first line contains one integer $n$ ($1 \leq n \leq 100$) — the number of floors.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \leq a_i \leq 100$) — the number of people on each floor.


-----Output-----

In a single line, print the answer to the problem — the minimum number of electricity units.


-----Examples-----
Input
3
0 2 1

Output
16
Input
2
1 1

Output
4


-----Note-----

In the first example, the answer can be achieved by choosing the second floor as the $x$-th floor. Each person from the second floor (there are two of them) would spend $4$ units of electricity per day ($2$ to get down and $2$ to get up), and one person from the third would spend $8$ units of electricity per day ($4$ to get down and $4$ to get up). $4 \cdot 2 + 8 \cdot 1 = 16$.

In the second example, the answer can be achieved by choosing the first floor as the $x$-th floor.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
line = input().split()
ans = 0
for i in range(n):
    ans += int(line[i])*i
print(4*ans)


def d(x,i,a):
    return 2*a*(abs(x-i) + abs(i-1) + abs(1-x))

n = int(input())
arr = [int(k) for k in input().split()]

def e(x):
    return sum(d(x,i+1,a) for (i,a) in enumerate(arr))

print(min(e(x) for x in range(1, n+1)))


n = int(input())
num = list(map(int, input().split()))
ans = 10 ** 18
for x in range(1, n + 1):
    res = 0
    for i in range(1, n + 1):
        res += (abs(x - i) + abs(i - 1) + abs(x - 1)) * num[i - 1]
    for i in range(1, n + 1):
        res += (abs(x - 1) + abs(i - 1) + abs(x - i)) * num[i - 1]
    ans = min(res, ans)
print(ans)

n=int(input())
a=list(map(int,input().split()))
costs=[]
for i in range(n):
    tot=0
    for j in range(n):
        tot+=4*a[j]*max((i,j))
    costs.append(tot)
print(min(costs))

n = int(input())
ans = 10000000000
a = [int(i) for i in input().split()]
for i in range(0, n):
    d = 0
    for j in range(n):
        d += 2 * a[j] * (abs(i - j) + j + i)
    ans = min(ans, d)
print(ans)


from sys import stdin, stdout
from math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial


n = int(stdin.readline())
values = list(map(int, stdin.readline().split()))
ans = float('inf')

for i in range(n):
    cnt = 0
    
    for j in range(n):
        cnt += values[j] * ((abs(i - j) + j + i) + (i + j + abs(j - i)))
    
    ans = min(ans, cnt)

stdout.write(str(ans))

n = int(input())
l = [*map(int, input().split())]
def cost(x):
    x -= 1
    res = 0
    for i in range(n):
        res += l[i] * (abs(x - i) + abs(i - 0) + abs(0 - x))
    return res
res = float('inf')
for x in range(1, n + 1):
    res = min(res, cost(x))
print(2 * res)

n = int(input())
a = list(map(int, input().split()))
min_en = 10000000000
for i in range(n):
    x = i
    en = 0
    for j in range(n):
        en += (abs(j - x) + abs(j) + abs(x)) * 2 * a[j]
    if en < min_en:
        min_en = en
print(min_en)


n=int(input())
h=list(map(int,input().split()))
ans=[]
for i in range (n):
    s=0
    for y in range (n):
        s+=(abs(i-y)+y+i+i+y+abs(i-y))*h[y]
    ans.append(s)
print(min(ans))


def cost(n,arr,x):
    tot = 0
    for i in range(n):
        tot +=(abs(x-i) + i + x)*arr[i]
    return tot*2
def prog():
    n = int(input())
    arr = [int(x) for x in input().split()]
    currcost = 10**18
    for i in range(n):
        currcost = min(currcost,cost(n,arr,i))
    return currcost
print(prog())

n = int(input())
a = list(map(int, input().split()))
minn = 10000000
for i in range(n):
    summ=0
    for j in range(n):
        summ+=a[j]*2*(abs(j)+abs(j-i)+abs(i))
    if summ<minn:
        minn=summ
print(minn)

n = int(input())
p = [int(k) for k in input().split()]

res = None
best = None
for x in range(1, n + 1):
    cur = 0
    for i, v in enumerate(p):
        cur += v * (abs(x - (i + 1)) + i + (x - 1) + x - 1 + i + abs(x - (i + 1)))
    if res is None or cur < res:
        res = cur
        best = x
print(res)

import math, sys, itertools

def mp():
    return list(map(int, input().split()))

def main():
    n = int(input())
    a = mp()
    ans = int(1e9)
    for i in range(n):
        res = 0
        for j in range(n):
            res += a[j] * (2 * i + 2 * abs(i - j) + 2 * j)
        # print(res)
        ans = min(ans, res)
    print(ans)
        

deb = 0
if deb:
    file = open('input.txt', 'r')
    input = file.readline
else:
    input = sys.stdin.readline
    
main()

n = int(input())

A = [int(x) for x in input().split()]

def cost(x):
  res = 0
  for i, a in enumerate(A):
    # Down:
    res += (abs(x-i) + abs(i-0) + abs(x-0)) * a

    # Up:
    res += (abs(x-0) + abs(0-i) + abs(i-x)) * a

  return res

print(min(cost(x) for x in range(len(A))))


n=int(input())
a=[int(s) for s in input().split()]
mn=float('inf')
for i in range(1,n+1):
    sum=0
    for j in range(n):
        sum+=a[j]*(abs(j+1-i)+j+i-1)*2
    mn=min(mn,sum)
print(mn)



import sys
def __starting_point():
    input = sys.stdin.read()
    n, *a = list(map(int, input.split()))
    sum1 = 0
    for i in range(len(a)):
        sum1+=a[i]*i*2
    print(sum1*2)
__starting_point()

from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
    n=int(stdin.readline())
    a=[0]+[int(x) for x in stdin.readline().split()]
    res=1
    minc=99999999999999999999999999999
    for x in range(1,n+1):
        c=0
        for i in range(1,n+1):
            c=c+(a[i]*(abs(i-x)+abs(i-1)+abs(1-x)  + abs(x-1)+abs(1-i)+abs(i-x)))
        if (c<minc):
            res=x
            minc=c
    stdout.write(str(minc))
    return 0

def __starting_point():
    main()
__starting_point()

n=int(input())
a=list(map(int,input().split()))
ans=10e9
for i in range(n):
    k=0
    for j in range(n):
        k+=(abs(j-i)+j+i)*a[j]*2
    ans=min(k,ans)
print(ans)


n = int(input())
arr = [int(x) for x in input().split()]


def get_for(x):
    nonlocal n, arr

    ret = 0
    for i in range(n):
        ret += (abs(x-i) + i + x) * arr[i] * 2

    return ret

mn = get_for(0)
for i in range(1, n):
    mn = min(mn, get_for(i))

print(mn)



n=int(input())
L=[int(i) for i in input().split()]
s=0
for i in range(len(L)):
    s=s+L[i]*i*4
print(s)


n = int(input())
a = list(map(int, input().split()))
m = float("inf")
for x in range(n):
    e = 0
    for f in range(n):
        e += a[f] * (abs(x - f) + f + x) * 2
    m = min(e, m)
print(m)


n = int(input())

a = list(map(int, input().split()))

ans = 0
e = 10 ** 9

for i in range(n):
    ne = 0
    for j in range(n):
        ne += (abs(i - j) + j + i) * 2 * a[j]

    if ne < e:
        e = ne
        ans = i

print(e)



n = int(input())
l = list(map(int, input().split()))

def f(x, l):
	s=0
	for i in range(len(l)):
		s+=l[i] * 2 * (abs(x-i)+abs(x)+abs(i))
	return s
q= 10**10
for x in range(n):
	q = min(f(x, l), q)
print(q)

n = int(input())

a = list(map(int, input().split(' ')))

def sol(x):
  total = 0
  for i in range(1, n + 1):
    current = abs(i - 1) + abs(x - i) + abs(x - 1)
    current *= 2 * a[i - 1]
    total += current

  return total

maxV = 100000000

for i in range(n):
  maxV = min(sol(i + 1), maxV)

print(maxV)

n = int(input())
a = [int(i) for i in input().split()]
m = 10 ** 9
for x in range(n):
    s = 0
    for b in range(n):
        i = x + 1
        j = b + 1
        s += a[b] * ((abs(i - j) + j - 1 + i - 1) * 2)
    m = min(m, s)
print(m)