Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2≤N≤2,000, a_i are integers, 1≤a_i≤10^9, 1≤x≤10^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.

# Buggy version:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,i = na()
a = na()
dp = [i for i in a]
ans = sum(dp)

for i in range(1,n):
    for j in range(n):
        dp[(j+i)%n] = min(dp[(j+i)%n], a[j])
    ans = min(ans, sum(dp)+x*i)

print(ans)

# Fixed version:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,x = na()
a = na()
dp = [i for i in a]
ans = sum(dp)

for i in range(1,n):
    for j in range(n):
        dp[(j+i)%n] = min(dp[(j+i)%n], a[j])
    ans = min(ans, sum(dp)+x*i)

print(ans)

# Buggy version:
from itertools import accumulate as acc
N, x, *A = map(int, open('0').read().split())
dp = []
for i in range(N):
  dp.append(list(acc((A[(i-j)%N] for j in range(N)),min)))

ans = 10**10
for i,a in enumerate(zip(*dp)):
  ans = min(ans,i*x+sum(a))
print(ans)

# Fixed version:
from itertools import accumulate as acc
N, x, *A = map(int, open(0).read().split())
dp = []
for i in range(N):
  dp.append(list(acc((A[(i-j)%N] for j in range(N)),min)))

ans = 10**60
for i,a in enumerate(zip(*dp)):
  ans = min(ans,i*x+sum(a))
print(ans)

# Buggy version:
import numpy as np
n, x = map(int, input().split())
A = np.array(input().split()[::-1], dtype=np.int64)
B = A.copy()
ans = float("inf")
for k in range(n):
  print(B)
  t = x*k + B.sum()
  ans = min(ans, t)
  np.minimum(B, np.roll(A, -k-1), out=B)
print(ans)

# Fixed version:
import numpy as np
n, x = map(int, input().split())
A = np.array(input().split()[::-1]*2, dtype=np.int64)
B = A.copy()[:n]
ans = float("inf")
for k in range(n):
  t = x*k + B.sum()
  ans = min(ans, t)
  np.minimum(B, A[k+1:k+n+1], out=B)
print(ans)

# Buggy version:
from collections import deque
from copy import deepcopy
n,x = map(int,input().split())
a = list(map(int,input().split()))
a *= 2
als = deepcopy(a[:n])
ans = [sum(als)]
for k in range(1,n):
  for i in range(n):
    als[i] = min(als[i],a[n-1+i-k])
  ans.append(sum(als)+x*k)
print(min(ans))

# Fixed version:
from copy import deepcopy
n,x = map(int,input().split())
a = list(map(int,input().split()))
a *= 2
als = deepcopy(a[:n])
ans = [sum(als)]
for k in range(1,n):
  for i in range(n):
    als[i] = min(als[i],a[n+i-k])
  ans.append(sum(als)+x*k)
print(min(ans))

# Buggy version:
n,x=map(int,input().split())
arr=list(map(int,input().split()))
cost=[10**10]*n
ans=10**10
for i in range(n):
  for j in range(n):
    cost[j]=min(cost[j],arr[j-i])
  print(cost)
  ans=min(ans,x*i+sum(cost))
print(ans)

# Fixed version:
n,x=map(int,input().split())
arr=list(map(int,input().split()))
cost=[10**18]*n
ans=10**18
for i in range(n):
  for j in range(n):
    cost[j]=min(cost[j],arr[j-i])
  ans=min(ans,x*i+sum(cost))
print(ans)

# Buggy version:

import numpy as np
N, x = map(int, input().split())
a = np.array(map(int, input().split()))
b = np.copy(a)
ans = float('inf') 
for i in range(N):
    c = np.roll(a,i)
    b = np.minimum(b,c)
    ans = min(ans, sum(b)+i*x)
print(ans)


# Fixed version:
import numpy as np
N, x = map(int, input().split())
a = np.array(list(map(int, input().split())))
b = np.copy(a)
ans = float('inf') 
for i in range(N):
    c = np.roll(a,i)
    b = np.minimum(b,c)
    ans = min(ans, sum(b)+i*x)
print(ans)

# Buggy version:
n, x = map(int, input().split())
a = list(map(int, input().split()))

DP = a[:]
ans = sum(DP)
for i in range(n-1):
    new = [0]*n
    for j in range(n):
        new[i] = min(DP[j], DP[j-1])
    DP=new
    ans = min(ans, sum(DP) + (i+1)*x)
print(ans)

# Fixed version:
n, x = map(int, input().split())
a = list(map(int, input().split()))

DP = a[:]
ans = sum(DP)
for i in range(n-1):
    new = [0]*n
    for j in range(n):
        new[j] = min(DP[j], DP[j-1])
    DP=new
    ans = min(ans, sum(DP) + (i+1)*x)
print(ans)

# Buggy version:
loop, magic_cost = map(int, input().split(" "))
cost = [n for n in map(int, input().split(" "))]
answer = float("inf")
min_costs = [float(inf) for n in range(loop)]
for i in range(loop):
    for j in range(loop):
        min_costs[j] = min(min_costs[j], cost[(i - j) % loop])
    answer = min(answer, sum(min_costs) + (magic_cost * (i) ) )
print(answer)

# Fixed version:
loop, magic_cost = map(int, input().split(" "))
cost = [n for n in map(int, input().split(" "))]
answer = float("inf")
min_costs = [float("inf") for n in range(loop)]
for i in range(loop):
    for j in range(loop):
        min_costs[j] = min(min_costs[j], cost[(i - j) % loop])
    answer = min(answer, sum(min_costs) + (magic_cost * (i) ) )
print(answer)

# Buggy version:
n,x = map(int,input().split())
a = list(map(int,input().split()))
MIN = sum(a)
tori = a + [0]
tori.pop()
for i in range(1,n):
  for j in range(n):
    ido = i+j
    if ido >= n:
      ido-=n
    tori[j] = min(a[ido],tori[j])
  MIN = sum(tori) + i*x
print(MIN)

# Fixed version:
n,x = map(int,input().split())
a = list(map(int,input().split()))
MIN = sum(a)
ans = MIN+0
tori = a + [0]
tori.pop()
for i in range(1,n):
  for j in range(n):
    ido = i+j
    if ido >= n:
      ido-=n
    if tori[j] > a[ido]:
      ans -= (tori[j] - a[ido])
      tori[j] = a[ido]
  MIN = min(ans + i*x,MIN)
print(MIN)

# Buggy version:
# coding:utf-8

INF = float('inf')


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


N, x = inpl()
A = inpl()

min_index = A.index(min(A))
B = A[min_index:] + A[:min_index]

cost = [B[i] for i in range(N)]

ans = INF
for magic in range(N):
    for i in range(N):
        if i - magic >= 0:
            cost[i] = min(cost[i], B[i - magic])

    ans = min(ans, sum(B) + x * magic)

print(ans)


# Fixed version:
# coding:utf-8

INF = float('inf')


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


N, x = inpl()
A = inpl()

min_index = A.index(min(A))
B = A[min_index:] + A[:min_index]

cost = [B[i] for i in range(N)]

ans = INF
for magic in range(N):
    for i in range(N):
        if i - magic >= 0:
            cost[i] = min(cost[i], B[i - magic])

    ans = min(ans, sum(cost) + x * magic)

print(ans)

# Buggy version:
def solve_():
    import itertools
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    s_cost = a.copy()
    cost = sum(s_cost)

    for k, i in itertools.product(range(1, N), range(N)):
        s_cost[i] = a[(i - k) % N] if s_cost > a[(i - k) % N] else s_cost[i]
        if i == N - 1 and cost > k*x + sum(s_cost):
            cost = k*x + sum(s_cost)
    
    print(cost)

solve()


# Fixed version:

def solve_():
    import itertools
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    s_cost = a.copy()
    cost = sum(s_cost)

    for k, i in itertools.product(range(1, N), range(N)):
        s_cost[i] = a[(i - k) % N] if s_cost[i] > a[(i - k) % N] else s_cost[i]
        if i == N - 1 and cost > k*x + sum(s_cost):
            cost = k*x + sum(s_cost)

    print(cost)

solve_()

# Buggy version:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9

def f():
    n,x = list(map(int, input().split()))
    a = list(map(int, input().split()))
    mi = a.index(min(a))
    a = a[mi:] + a[:mi]
    print("a",a)
    r = sum(a)
    for t in range(n-1):
        for i in range(n-1,0,-1):
            a[i] = min(a[i],a[i-1])
        tr = ((t+1)*x) + sum(a)
        if r > tr:
            r = tr
        else:
            break
    return r

print(f())


# Fixed version:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9

def f():
    n,x = list(map(int, input().split()))
    a = list(map(int, input().split()))
    mi = a.index(min(a))
    a = a[mi:] + a[:mi]
    r = sum(a)
    for t in range(n-1):
        for i in range(n-1,0,-1):
            a[i] = min(a[i],a[i-1])
        tr = ((t+1)*x) + sum(a)
        if r > tr:
            r = tr
        else:
            break
    return r

print(f())