import sys

input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(max(1000, 10**9))

write = lambda x: sys.stdout.write(x+"\n")







from queue import deque

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

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



def sub(p):

    k = p

    res = []

    q = deque([])

    # q: i0<i1<,..., a_i0>a_i1>,...であるようなi0, i1,... のキュー

    for i,num in enumerate(a):

        while q and a[q[-1]]>num:

            q.pop()

        q.append(i)

        if q[0]<=i-k:

            q.popleft()

        if i>=k-1:

            m = a[q[0]] # i-k+1,...iの中の最小値

            res.append(m)

    for j,num in enumerate(a):

        if len(res)>=n:

            break

        while q and a[q[-1] if q[-1]<n else q[-1]-n]>num:

            q.pop()

        q.append(j+n)

        if q[0]<=j+n-k:

            q.popleft()

        m = a[q[0] if q[0]<n else q[0]-n] # i-k+1,...iの中の最小値

        res.append(m)

    return sum(res)





ans = 10**15

for p in range(n):

    ans = min(ans, sub(p+1) + x*p)

print(ans)
import sys

input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(max(1000, 10**9))

write = lambda x: sys.stdout.write(x+"\n")







from queue import deque

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

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



def sub(p):

    k = p

    res = []

    q = deque([])

    a = A + A[:k-1]

    # q: i0<i1<,..., a_i0>a_i1>,...であるようなi0, i1,... のキュー

    for i,num in enumerate(a):

        while q and a[q[-1]]>num:

            q.pop()

        q.append(i)

        if q[0]<=i-k:

            q.popleft()

        if i>=k-1:

            m = a[q[0]] # i-k+1,...iの中の最小値

            res.append(m)

    return sum(res)





ans = 10**15

for p in range(n):

    ans = min(ans, sub(p+1) + x*p)

print(ans)
import sys

input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
from queue import deque

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


def sub(p):
    k = p
    res = []
    q = deque([])
    # q: i0<i1<,..., a_i0>a_i1>,...であるようなi0, i1,... のキュー
    for i, num in enumerate(a):
        while q and a[q[-1]] > num:
            q.pop()
        q.append(i)
        if q[0] <= i - k:
            q.popleft()
        if i >= k - 1:
            m = a[q[0]]  # i-k+1,...iの中の最小値
            res.append(m)
    for j, num in enumerate(a):
        if len(res) >= n:
            break
        while q and a[q[-1] if q[-1] < n else q[-1] - n] > num:
            q.pop()
        q.append(j + n)
        if q[0] <= j + n - k:
            q.popleft()
        m = a[q[0] if q[0] < n else q[0] - n]  # i-k+1,...iの中の最小値
        res.append(m)
    return sum(res)


ans = 10**15
for p in range(n):
    ans = min(ans, sub(p + 1) + x * p)
print(ans)

import sys

input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
from queue import deque

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


def sub(p):
    k = p
    res = []
    q = deque([])
    a = A + A[: k - 1]
    # q: i0<i1<,..., a_i0>a_i1>,...であるようなi0, i1,... のキュー
    for i, num in enumerate(a):
        while q and a[q[-1]] > num:
            q.pop()
        q.append(i)
        if q[0] <= i - k:
            q.popleft()
        if i >= k - 1:
            m = a[q[0]]  # i-k+1,...iの中の最小値
            res.append(m)
    return sum(res)


ans = 10**15
for p in range(n):
    ans = min(ans, sub(p + 1) + x * p)
print(ans)

-a = list(map(int, input().split())) +A = list(map(int, input().split())) +    a = A + A[: k - 1] -    for j, num in enumerate(a): -        if len(res) >= n: -            break -        while q and a[q[-1] if q[-1] < n else q[-1] - n] > num: -            q.pop() -        q.append(j + n) -        if q[0] <= j + n - k: -            q.popleft() -        m = a[q[0] if q[0] < n else q[0] - n]  # i-k+1,...iの中の最小値 -        res.append(m)