Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from itertools import accumulate


def solve(N: int, X: int, x: "List[int]"):
    coeff = [2*i+1 if i>=3 else 5 for i in range(N+1)]
    acc = list(accumulate([0]+x))
    tmp = 0
    for i in range(N):
        tmp += coeff[N-i]*x[i]
    tmp += N*X+X
    ans = tmp
    M = N
    for i in range(2, N+1):
        #M -= 2
        #if M<1:
        #    break
        #tmp -= 4*acc[(coeff[M+2]-5)//2-1] + 2*x[(coeff[M+2]-5)//2-1]
        #tmp += X
        def tmp_iter():
            cnt = 0
            p, q = -(-N//i), N%i
            if q>0:
                for _ in range(q):
                    cnt += 1
                    yield coeff[p]
                    if cnt==N:
                        break
            else:
                p += 1
            while cnt<N:
                p -= 1
                for j in range(i):
                    cnt += 1
                    yield coeff[p]
                    if cnt==N:
                        break
        tmp_ans = 0
        for k, elem in enumerate(tmp_iter()):
            #print(i, k, elem)
            tmp_ans += elem*x[k]
        tmp_ans += N*X+i*X

        ans = min(ans, tmp_ans)
    print(ans)



    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    X = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, X, x)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from itertools import accumulate


def solve(N: int, X: int, x: "List[int]"):
    coeff = [2*i+1 if i>=3 else 5 for i in range(N+1)]
    acc = list(accumulate([0]+x))
    tmp = 0
    for i in range(N):
        tmp += coeff[N-i]*x[i]
    tmp += N*X+X
    ans = tmp
    for i in range(2, N+1):
        #def tmp_iter():
        #    cnt = 0
        #    p, q = -(-N//i), N%i
        #    if q>0:
        #        for _ in range(q):
        #            cnt += 1
        #            yield coeff[p]
        #            if cnt==N:
        #                break
        #    else:
        #        p += 1
        #    while cnt<N:
        #        p -= 1
        #        for j in range(i):
        #            cnt += 1
        #            yield coeff[p]
        #            if cnt==N:
        #                break
        #for k, elem in enumerate(tmp_iter()):
        #    print(i, k, elem)
        #    tmp_ans += elem*x[k]
        #tmp_ans += N*X+i*X
        tmp_ans = 0
        p, q = N//i, N%i
        for j in range(p):
            tmp_ans += coeff[p-j]*(acc[q+i*(j+1)]-acc[q+i*j])
        if q>0:
            tmp_ans += coeff[p+1]*acc[q]
        tmp_ans += N*X+i*X

        ans = min(ans, tmp_ans)
    print(ans)

    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    X = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, X, x)

if __name__ == '__main__':
    main()