Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together.

Snuke can perform the following two actions:

* Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds.

* Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds.




Find the minimum time that Snuke needs to have slimes in all N colors.

Constraints

* 2≤N≤2,000
* a_i are integers.
* 1≤a_i≤10^9
* x is an integer.
* 1≤x≤10^9

Input

The input is given from Standard Input in the following format:


N x
a_1 a_2 ... a_N


Output

Find the minimum time that Snuke needs to have slimes in all N colors.

Examples

Input

2 10
1 100


Output

12


Input

3 10
100 1 100


Output

23


Input

4 10
1 2 3 4


Output

10
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        this.ColorCount = (int)(inpt[0]);
        this.MahoCost = inpt[1];

        this.CatchCost = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        this.BaseAns = this.CatchCost.Sum(a => a);

        long ans = this.GetAns(new bool[ColorCount], 0);
        if (ans < 0)
        {
            ans = this.BaseAns;
        }
        Console.WriteLine(ans.ToString("########################################0"));
    }

    private int ColorCount;
    private long MahoCost;
    private long[] CatchCost;

    private long BaseAns = 0;

    private Dictionary<String, long> dic = new Dictionary<string, long>();
    private long GetAns(bool[] flags, long subTotal) {
        string key = string.Join(string.Empty, flags.Select(a => a ? 1 : 0));
        if (dic.ContainsKey(key))
        {
            return dic[key];
        }
        if (subTotal > this.BaseAns)
        {
            return -1;
        }
        long ans = BaseAns;

        if (!flags.Contains(false))
        {
            ans = 0;
        }
        else
        {
            long ret;
            for (int i = 0; i < ColorCount; i++)
            {
                if (!flags[i])
                {
                    flags[i] = true;
                    ret = this.GetAns(flags, subTotal + this.CatchCost[i]);
                    if (ret >= 0)
                    {
                        ans = Math.Min(ans, ret + this.CatchCost[i]);
                    }
                    flags[i] = false;

                }
            }
            bool[] subFlags = new bool[ColorCount];
            for (int j = 0; j < ColorCount; j++)
            {
                int idx = j + 1;
                if (idx >= ColorCount)
                {
                    idx = 0;
                }
                subFlags[idx] = flags[j];
            }
            ret = this.GetAns(subFlags, subTotal + MahoCost);
            if (ret > 0)
            {
                ans = Math.Min(ans, ret + MahoCost);
            }
        }
        dic[key] = ans;
        return ans;
    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"





4 10
1 2 3 4



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}