Buggy python submission (verdict: Time Limit Exceeded):
# coding:utf-8


INF = float('inf')


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


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    tmp = 0
    i = 0
    cur = N - k
    while True:
        e = 5 if i == 0 else 2 * i + 3
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        i += 1
        cur -= k

    ans = min(ans, tmp + (N + k) * X)

print(ans)

Fixed submission:
# coding:utf-8


INF = float('inf')


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


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    e = 5
    cur = N - k
    tmp = e * (B[N] - B[cur]) + (N + k) * X
    cur -= k
    while True:
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        e += 2
        cur -= k

    ans = min(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding:utf-8


INF = float('inf')


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


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    tmp = 0
    i = 0
    cur = N
    while True:
        e = 5 if i == 0 else 2 * i + 3
        tmp += e * (B[cur] - B[max(cur - k, 0)])
        if cur - k <= 0:
            break
        i += 1
        cur -= k

    ans = min(ans, tmp + (N + k) * X)

print(ans)

Fixed submission:
# coding:utf-8


INF = float('inf')


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


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    e = 5
    cur = N - k
    tmp = e * (B[N] - B[cur]) + (N + k) * X
    cur -= k
    while True:
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        e += 2
        cur -= k

    ans = min(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding:utf-8


INF = float('inf')


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


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(N):
    tmp = 0
    i = 0
    t = 0
    while True:
        e = 5 if i == 0 else 2 * i + 3
        # print(N - t, e)

        if N - t - (k + 1) < 0:
            tmp += e * B[N - t]
            break
        else:
            tmp += e * (B[N - t] - B[N - t - (k + 1)])

        i += 1
        t += k + 1

    ans = min(ans, tmp + (N + k + 1) * X)

print(ans)

Fixed submission:
# coding:utf-8


INF = float('inf')


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


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    e = 5
    cur = N - k
    tmp = e * (B[N] - B[cur]) + (N + k) * X
    cur -= k
    while True:
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        e += 2
        cur -= k

    ans = min(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding:utf-8

import math


INF = float('inf')


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


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

E = [2 * (i + 1) + 1 for i in range(N)]
E[0] = 5

ans = INF
for k in range(1, N + 1):
    tmp = 0
    for i in range(1, N + 1, k):
        if N + 1 - i - k < 0:
            tmp += E[math.ceil(i / k) - 1] * (B[N - i + 1])
        else:
            tmp += E[math.ceil(i / k) - 1] * (B[N - i + 1] - B[N - i - k + 1])
        # print(k, i, tmp)

    ans = min(ans, tmp + (N + k) * X)
    # print(ans)

print(ans)

Fixed submission:
# coding:utf-8


INF = float('inf')


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


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    e = 5
    cur = N - k
    tmp = e * (B[N] - B[cur]) + (N + k) * X
    cur -= k
    while True:
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        e += 2
        cur -= k

    ans = min(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding:utf-8

import math


INF = float('inf')


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


N, X = inpl()
A = inpl()
E = [2 * (i + 1) + 1 for i in range(N)]
E[0] = 5
# print(E)
ans = INF
for k in range(1, N + 1):
    tmp = 0
    for i in range(1, N + 1):
        tmp += E[math.ceil(i / k) - 1] * A[N - i]

    ans = min(ans, tmp + (N + k) * X)
    # print(ans)

print(ans)

Fixed submission:
# coding:utf-8


INF = float('inf')


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


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    e = 5
    cur = N - k
    tmp = e * (B[N] - B[cur]) + (N + k) * X
    cur -= k
    while True:
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        e += 2
        cur -= k

    ans = min(ans, tmp)

print(ans)