Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

# -*- coding: utf-8 -*-

H = int(input())

ans = 1
prev = 1
while True:
    H //= 2
    prev *= 2
    ans += prev
    if H == 1:
        break

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-

H = int(input())

ans = 1
prev = 1
while True:
    if H == 1:
        break
    H //= 2
    prev *= 2
    ans += prev

print(ans)
### BUGGY CODE ###

def f(q):
    global H,W,A
    B = []
    for Q in q:
        h,w = Q[0],Q[1]
        if h+1!=H and A[h+1][w]==".":
            B.append([h+1,w])
            A[h+1][w]="#"
        if h-1!=-1 and A[h-1][w]==".":
            B.append([h-1,w])
            A[h-1][w]="#"
        if w+1!=W and A[h][w+1]==".":
            B.append([h,w+1])
            A[h][w+1]="#"
        if w-1!=-1 and A[h][w-1]==".":
            B.append([h,w-1])
            A[h][w-1]="#"
    return B
H,W = map(int,input().split())
A = [list(input()) for i in range(H)]
ans = 0
q = []
for h in range(H):
    for w in range(W):
        if A[h][w]=="#": q.append([h,w])
while q:
    ans+=1
    q = f(q)
print(ans-1)

### FIXED CODE ###

H,W = map(int,input().split())
A = [list(input()) for i in range(H)]
S = [[0]*W for i in range(H)]
for h in range(H):
    for w in range(W):
        if A[h][w]=="#":
            S[h][w] = H*W
for h in range(H):
    a = 0
    for w in range(W):
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
    for w in range(W)[::-1]:
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
for w in range(W):
    a = 0
    for h in range(H):
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
    for h in range(H)[::-1]:
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
ans = H*W
for h in range(H):
    for w in range(W):
        ans = min(ans,S[h][w])
print(H*W-ans)
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N, X, Y = LI()
X -= 1
Y -= 1
path = [[mod for i in range(N)] for i in range(N)]
for i in range(N):
    for j in range(N):
        path[i][j] = abs(i - j)
        path[j][i] = abs(j - i)
    
path[X][Y] = 1
path[Y][X] = 1


for i in range(N):
    for j in range(i + 1, N):
        path[i][j] = min(path[i][j], path[i][X] + path[Y][j] + 1)
        path[j][i] = min(path[i][j], path[i][X] + path[Y][j] + 1)
        

anss = [0 for i in range(N)]
# for p in path:
#     print(p)

for i in range(N):
    for j in range(N):
        anss[path[i][j]] += 1

for i in range(1, N):
    print(anss[i] // 2)

### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N, X, Y = LI()
X -= 1
Y -= 1
anss = [0 for i in range(N)]

for i in range(N):
    for j in range(i + 1, N):
        anss[min(
            abs(i - j), 
            abs(X - i) + 1 + abs(j - Y),
            abs(Y - i) + 1 + abs(X - j)
        )] += 1

for i in range(1, N):
    print(anss[i])
### BUGGY CODE ###

h = int(input())
monster = [h]
ans = 0
while len(monster) >= 1:
  for index,m in enumerate(monster):
    if m == 1:
      ans += 1
      del monster[index]
    else:
      ans += 1
      del monster[index]
      new = m // 2
      monster.append(new)
      monster.append(new)
print(ans)

### FIXED CODE ###

import math
h = int(input())
num = math.log(h,2)
num = int(num)
ans = 0
for i in range(num+1):
  ans += 2**i

print(ans)
### BUGGY CODE ###

import numpy as np
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

calc_expectedval = (lambda p: sum(range(p+1)) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

convolved = np.convolve(expected_vals, np.ones(k))

print(max(convolved))

### FIXED CODE ###

n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

continuous_sum = (lambda n: (n + 1) * (n // 2) + (0 if n %2 == 0 else n // 2 + 1))
calc_expectedval = (lambda p: continuous_sum(p) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

prevval = sum(expected_vals[0:0+k])
maxval = prevval
for i in range(n - k):
  candidate = prevval - expected_vals[i] + expected_vals[i + k]
  if candidate > maxval:
    maxval = candidate
  prevval = candidate

print(maxval)
### BUGGY CODE ###

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

cnt=0
for i in range(1,n):
    
    # 条件満たすまでループ
    while True:
        #print(a[:i])
    
        now_tmp = sum(a[:i])
        next_tmp = sum(a[:i+1])
        #print(now_tmp, next_tmp)
        
        # 符号が逆転していればOK かつ 現在までの総和が0でない
        #  異なる符号を掛けるとマイナスになる
        if now_tmp * next_tmp <0 and now_tmp !=0:
            break
        else:
            # 現在の合計がマイナスの場合
            if sum(a[:i]) < 0 :
                a[i] +=1
                cnt +=1

            # 現在の合計がプラスの場合
            elif sum(a[:i]) > 0 :
                a[i] -=1
                cnt +=1
            # 現在の合計が0の場合
            elif sum(a[:i]) == 0 :
                a[i] +=1
                cnt +=1
                
print(cnt)

### FIXED CODE ###

n = list(input().split())

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

# flg:True プラスの想定
def chk(A, flg):
    #print("-------")
    # 初期値
    x=0
    ans =0
    for a in A:
        # 今までの合計
        x += a
        
        # 想定と違ったら、1との差分を増減する
        if flg==True and x < 1:
            ans +=1-x
            # xは1に変える
            x=1
        elif flg == False and x> -1:
            ans += x+1
            x=-1
        #print(x)
        flg = not flg

    return(ans)
print(min(chk(A, True),chk(A, False)))
### BUGGY CODE ###

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a += [a[-1]]*k

    dp = [10**10]*(n+k)
    dp[0] = 0
    for i in range(n-1):
        for j in range(1, k+1):
            dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]))

    print(dp[n-1])


main()

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a += [a[-1]]*k

    dp = [10**10]*(n+k)
    dp[0] = 0
    for i in range(n-1):
        for j in range(1, k+1):
            dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]))

    print(dp[n-1])


main()
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
import functools
INF = float("inf")

MOD = 1000000007  # type: int


def GCD(a, b):
    if a == 0:
        return b
    else:
        return GCD(b % a, a)


def LCM(a, b):
    return a*b//GCD(a, b)


def solve(N: int, A: "List[int]"):

    # 最小公倍数
    lcm = 1
    for a in A:
        if lcm % a == 0:
            continue
        lcm = LCM(lcm, a)

    @functools.lru_cache(maxsize=None)
    def f(a):
        return (lcm//a) % MOD
    tot = 0
    for a in A:
        tot += f(a)
    print(tot % MOD)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import Counter
import math
MOD = 1000000007  # type: int


def factorial(n):
    prime_count = Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % MOD
    elif y % 2 == 0:
        return power(x, y//2)**2 % MOD
    else:
        return power(x, y//2)**2 * x % MOD


def div(a, b):
    return (a * power(b, MOD-2)) % MOD


def solve(N: int, A: "List[int]"):

    lcm = Counter()
    for a in A:
        c = factorial(a)
        for k in c:
            lcm[k] = max(c[k], lcm[k])
    # print(lcm)

    LCM = 1
    for k, v in lcm.items():
        LCM *= power(k, v)
        LCM %= MOD
    # print(LCM)

    tot = 0
    for a in A:
        tot += div(LCM, a)
    print(tot % MOD)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N, K = map(int, input().split())
S = input()

def solve():
    global K, S
    concat_S = S[:]
    while 'LL' in concat_S:
        concat_S = concat_S.replace('LL', 'L', 1)
    while 'RR' in concat_S:
        concat_S = concat_S.replace('RR', 'R', 1)

    ans = len(S) - len(concat_S)
    if len(concat_S) >= 4:
        # 2個ずつ消す
        num_rm = min(K, (len(concat_S)-2)//2)
        K -= num_rm
        ans += num_rm * 2
        len_concat_S = len(S) - ans

        if K:
            if len_concat_S == 3:
                ans += 2
            elif len_concat_S == 2:
                ans += 1
        print(ans)
        return
    if K:
        if len(concat_S) == 3:
            ans += 2
        elif len(concat_S) == 2:
            ans += 1
        
    print(ans)
    return

if __name__ == "__main__":
    solve()

### FIXED CODE ###

N, K = map(int, input().split())
S = input()

def solve():
    global K, S
    concat_S = S[:]
    while 'LL' in concat_S:
        concat_S = concat_S.replace('LL', 'L')
    while 'RR' in concat_S:
        concat_S = concat_S.replace('RR', 'R')

    ans = len(S) - len(concat_S)
    if len(concat_S) >= 4:
        # 2個ずつ消す
        num_rm = min(K, (len(concat_S)-2)//2)
        K -= num_rm
        ans += num_rm * 2
        len_concat_S = len(S) - ans

        if K:
            if len_concat_S == 3:
                ans += 2
            elif len_concat_S == 2:
                ans += 1
        print(ans)
        return
    if K:
        if len(concat_S) == 3:
            ans += 2
        elif len(concat_S) == 2:
            ans += 1
        
    print(ans)
    return

if __name__ == "__main__":
    solve()
### BUGGY CODE ###

N, M = map(int, input().split(' '))

data = []
for m in range(M):
    data.append(list(map(int, input().split(' '))))

cnt = 0
for n in range(1, N+1):
    flg = 0
    for m in range(M):
        li, ri = data[m]
        if li <= n <= ri:
            flg += 1
    if flg == M:
        cnt += 1
print(cnt)

### FIXED CODE ###

N, M = map(int, input().split(' '))
 
data = []
l = 1
r = 10**5
for m in range(M):
    li, ri = map(int, input().split(' '))
    if li > l:
      l = li
    if ri < r:
      r = ri
 
if l<= N <= r:
  cnt = (N - l) + 1
elif l > r:
  cnt = 0
elif r < N:
  cnt = (r - l) + 1
else:
  cnt = 0
 
print(cnt)
### BUGGY CODE ###

h,w = map(int,input().split())
s = [input() for i in range(h)]


p = []
append1 = p.append
for i in range(h):
    q = []
    t = False
    now = 0
    for j in range(w):
        if s[i][j] == '.':
            t = True
            now += 1
            if j == w-1:
                q = q + [now for _ in range(now)]
        else:
            if t:
                q = q + [now for _ in range(now)] + [0]
                t = False
                now = 0
            else:
                q = q + [0]
                now = 0
    append1(q)
p2 = []
append2 = p2.append
for i in range(w):
    r = []
    t = False
    now = 0
    for j in range(h):
        if s[j][i] == '.':
            t = True
            now += 1
            if j == h-1:
                r = r + [now for _ in range(now)]
        else:
            if t:
                r = r + [now for _ in range(now)] + [0]
                t = False
                now = 0
            else:
                r = r + [0]
                now = 0
    append2(r)

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans,p[i][j] + p2[j][i]-1)

print(ans)

### FIXED CODE ###

h,w = map(int,input().split())
s = [input() for i in range(h)]

left =[[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if j == 0:
            if s[i][j] == '.':
                left[i][j] = 1
        else:
            if s[i][j] == '.':
                left[i][j] = left[i][j-1] + 1
            else:
                left[i][j] = 0

right =[[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w-1,-1,-1):
        if j == w-1:
            if s[i][j] == '.':
                right[i][j] = 1
        else:
            if s[i][j] == '.':
                right[i][j] = right[i][j+1] + 1
            else:
                right[i][j] = 0

forward =[[0 for _ in range(w)] for _ in range(h)]

for j in range(w):
    for i in range(h):
        if i == 0:
            if s[i][j] == '.':
                forward[i][j] = 1
        else:
            if s[i][j] == '.':
                forward[i][j] = forward[i-1][j] + 1
            else:
                forward[i][j] = 0

backward =[[0 for _ in range(w)] for _ in range(h)]
for j in range(w):
    for i in range(h-1,-1,-1):
        if i == h-1:
            if s[i][j] == '.':
                backward[i][j] = 1
        else:
            if s[i][j] == '.':
                backward[i][j] = backward[i+1][j] + 1
            else:
                backward[i][j] = 0

ans = 0
for i in range(h):
    for j in range(w):
        now = right[i][j]+left[i][j]+forward[i][j]+backward[i][j]-3
        ans = max(ans,now)

print(ans)
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
m=0
for i in range(max(A),0,-1):
    count=0
    for a in A:
        if a%i==0:count+=1
        if count>=n-1:
            print(i)
            exit()

### FIXED CODE ###

from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
R,L=[0],[0]
for i in range(N-1):
    R+=[gcd(R[i],A[i])]
    L+=[gcd(L[i],A[-i-1])]
print(max(gcd(R[i],L[-i-1]) for i in range(N)))
### BUGGY CODE ###

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# 早期終了

if len(set(A)) != len(A):
    print(0)
    exit()
if len(set(B)) != len(B):
    print(0)
    exit()

# 高速化のため事前ソート

# A.sort(reverse=True)結局使わなかった
# B.sort(reverse=True)

n_A, n_B = 0, 0  # ある数よりも大きい要素数(単調増加)
# この問題は場合分けを思いつけるか、計算量を減らせるかにかかっている
# 与えられた集合の中にxょり大きい要素がいくつあるかという処理に大きく時間がかかっている
# これをn_Aとおくと、n_Aには単調増加性があることがすぐにわかる
# xをどんどん小さくしているからである。
# n_Aを逐一計算する代わりに、いままでの情報を使ってn_Aを求められると処理が高速化される
# A=[182, 181, 180, 179, 178, 176, 175, 169, 168, 167, 158, 151, 147, 129]とする(sorted)とすると、
# A[n_A]=xとなるn_Aがほしい。xが登場するまでのイテレーションでx_pre in Aとなる要素があるたび、その回数をカウントすればよい
#


def ret_n_given_x(x):
    global n_A, n_B
    flgA = True if x in A else False
    flgB = True if x in B else False
    # print(flgA, flgB)
    if flgA and flgB:
        n_A += 1  # 上記で解説した個数カウント
        n_B += 1  # xより大きな要素が何個あったかついでに記録できる
        return 1
    elif flgA:
        n_A += 1
        return n_B
    elif flgB:
        n_B += 1
        return n_A
    else:
        return (n_A * n_B)-(N*M-x)


MOD = 10**9 + 7
ans = 1
for x in range(N * M, 0, -1):
    ans *= ret_n_given_x(x)
    ans %= MOD
    # print(x, ans, ret_n_given_x(x))
    if ans == 0:
        break

print(int(ans))


### FIXED CODE ###

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# 早期終了

if len(set(A)) != len(A):
    print(0)
    exit()
if len(set(B)) != len(B):
    print(0)
    exit()

# 高速化のため事前ソート

A.sort(reverse=True)
B.sort(reverse=True)

n_A, n_B = 0, 0  # ある数よりも大きい要素数(単調増加)
# この問題は場合分けを思いつけるか、計算量を減らせるかにかかっている
# 与えられた集合の中にxょり大きい要素がいくつあるかという処理に大きく時間がかかっている
# これをn_Aとおくと、n_Aには単調増加性があることがすぐにわかる
# xをどんどん小さくしているからである。
# n_Aを逐一計算する代わりに、いままでの情報を使ってn_Aを求められると処理が高速化される
# A=[182, 181, 180, 179, 178, 176, 175, 169, 168, 167, 158, 151, 147, 129]とする(sorted)とすると、
# A[n_A]=xとなるn_Aがほしい。xが登場するまでのイテレーションでx_pre in Aとなる要素があるたび、その回数をカウントすればよい
#


def ret_n_given_x(x):
    global n_A, n_B
    flgA = False
    flgB = False
    for a in A[n_A:]:
        if a == x:
            flgA = True
            break
    for a in B[n_B:]:
        if a == x:
            flgB = True
            break
    if flgA and flgB:
        n_A += 1  # 上記で解説した個数カウント
        n_B += 1  # xより大きな要素が何個あったかついでに記録できる
        return 1
    elif flgA:
        n_A += 1
        return n_B
    elif flgB:
        n_B += 1
        return n_A
    else:
        return (n_A * n_B)-(N*M-x)


MOD = 10**9 + 7
ans = 1
for x in range(N * M, 0, -1):
    ans *= ret_n_given_x(x)
    ans %= MOD
    # print(x, ans, ret_n_given_x(x))
    if ans == 0:
        break

print(int(ans))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
counter = 0
for j in range(1, N):
    for i in range(j + 1, N + 1):
        if j + A[j-1] == i - A[i-1]:
            counter += 1
print(counter)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
dic = {}
dic[1 + A[0]] = 1
for i in range(2, N+1):
    if i - A[i-1] in dic:
        ans += dic[i - A[i-1]]
    if i + A[i-1] in dic:
        dic[i + A[i-1]] = dic[i + A[i-1]] + 1
    else:
        dic[i + A[i-1]] = 1
print(ans)
### BUGGY CODE ###

from itertools import combinations
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors


#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

A, B = map(int, input().split())

di_A = make_divisors(A)
di_B = make_divisors(B)

di_C = list(set(di_A) & set(di_B))
if len(di_C)==1:
    print(1)
    exit()

ans = 0
array = []
array_not = []
edges = [[False] * len(di_C) for _ in range(len(di_C))]
for i in range(len(di_C)):
    for j in range(i+1, len(di_C)):
        if gcd(di_C[i], di_C[j])==1:
            edges[i][j]=True

for num in range(len(di_C), 0, -1):
    fraction = combinations(range(len(di_C)), num)
    for relation in fraction:
        judge = []
        for i, j in combinations(relation, 2):
            judge.append(edges[i][j])
        if all(judge):
            ans = num
            print(ans)
            exit()
print(ans)



### FIXED CODE ###



def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr



A, B = map(int, input().split())

fac_A = factorization(A)
fac_B = factorization(B)

prime_A = [f[0] for f in fac_A]
prime_B = [f[0] for f in fac_B]

if 1 in prime_A: prime_A.remove(1)
if 1 in prime_B: prime_B.remove(1)
common = set(prime_A) & set(prime_B)
print(len(common)+1)
### BUGGY CODE ###

N, Q = map(int, input().split())
root = [[] for _ in range(N + 10)]
counter = [0 for _ in range(N + 10)]
for _ in range(N - 1):
  a, b = map(int, input().split())
  root[a].append(b)
  root[b].append(a)
for _ in range(Q):
  p, x = map(int, input().split())
  counter[p] += x
queue = [1]
while queue:
  vertex = queue.pop(0)
  for v in root[vertex]:
    counter[v] += counter[vertex]
    queue.append(v)
    root[v].remove(vertex)
for i in range(1, N):
  print('{} '.format(counter[i]), end='')
print(counter[N])

### FIXED CODE ###

N, Q = map(int, input().split())
root = [[] for _ in range(N + 10)]
counter = [0 for _ in range(N + 10)]
for _ in range(N - 1):
  a, b = map(int, input().split())
  root[a].append(b)
  root[b].append(a)
for _ in range(Q):
  p, x = map(int, input().split())
  counter[p] += x
from collections import deque
d = deque([1])
while d:
  vertex = d.pop()
  for v in root[vertex]:
    counter[v] += counter[vertex]
    d.append(v)
    root[v].remove(vertex)
for i in range(1, N):
  print('{} '.format(counter[i]), end='')
print(counter[N])
### BUGGY CODE ###

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

b = []
start = n // 2 + 1
end = n
num = [0] * n
while True:
    if start > end:
        break
    else:
        for i in range(end, start - 1, -1):
            if a[i - 1] != num[i - 1]:
                b.append(i)
                divisors = make_divisors(i)
                for j in divisors:
                    a[j - 1] += 1
                    a[j - 1] %= 2
        end = start - 1
        start = end // 2 + 1
b.sort()
print(len(b))
if len(b) >= 2:
    print(" ".join(map(str, b)))
elif len(b) == 1:
    print(b[0])
else:
    pass

### FIXED CODE ###

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

b = []
start = n // 2 + 1
end = n
num = [0] * n
while True:
    if start > end:
        break
    else:
        for i in range(end, start - 1, -1):
            if a[i - 1] != num[i - 1]:
                b.append(i)
                divisors = make_divisors(i)
                for j in divisors:
                    a[j - 1] += 1
                    a[j - 1] %= 2
        end = start - 1
        start = end // 2 + 1
b.sort()
print(len(b))
if len(b) >= 2:
    print(" ".join(map(str, b)))
elif len(b) == 1:
    print(b[0])
else:
    pass
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

mod = 1000000007
INF = 110110110

N = int(input())
A = list(map(int, input().split()))
PA = []
for i in range(N):
    PA.append((A[i], i))
PA.sort(reverse=True)

dp = [[0 for j in range(N+1)] for i in range(N+1)]

for i in range(N+1):
    for j in range(N+1):
        dp[i][j] = -INF * INF

dp[0][0] = 0

for i in range(N):
    for j in range(N):
        if i+j >= N:
            continue
        w = PA[i+j][0]
        at = PA[i+j][1]
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + w * abs(at - i))
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + w * abs(at - (N-1-j)))
ans = 0
for i in range(N+1):
    for j in range(N+1):
        ans = max(ans, dp[i][j]);
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

mod = 1000000007
INF = 110110110

N = int(input())
A = list(map(int, input().split()))
PA = []
for i in range(N):
    PA.append((A[i], i))
PA.sort(reverse=True)

dp = [[0 for j in range(N+1)] for i in range(N+1)]

for i in range(N+1):
    for j in range(N+1):
        dp[i][j] = -INF * INF

dp[0][0] = 0

for i in range(N):
    for j in range(N):
        if i+j >= N:
            continue
        w = PA[i+j][0]
        at = PA[i+j][1]
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + w * abs(at - i))
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + w * abs(at - (N-1-j)))
ans = 0
for i in range(N+1):
    for j in range(N+1):
        ans = max(ans, dp[i][j]);
print(ans)