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
package main

import (
    "fmt"
    "math"
)

func solve2(N int64, x int64, a []int64, maxshift int64) int64 {
    numShiftMax := int64(0)
    secsMinPos := make([]int64, N)
    // iの位置のスライムは、どこから来るのが早いのか
    for i := int64(0); i < N; i++ {
        secsMin := int64(math.MaxInt64)
        for nshift := int64(0); nshift <= maxshift; nshift++ {
            pos := i - nshift
            if pos < 0 {
                pos += N
            }
            // posの位置からnshift回shiftしてきたとする
            secs := a[pos] + nshift*x
            if secs < secsMin {
                secsMin = secs
                secsMinPos[i] = pos
                if nshift > numShiftMax {
                    numShiftMax = nshift
                }
            }
        }
    }

    var total int64
    for i := int64(0); i < N; i++ {
        total += int64(a[secsMinPos[i]])
    }
    total += int64(x) * int64(numShiftMax)
    return total
}

func solve(N int64, x int64, a []int64) int64 {
    min := int64(math.MaxInt64)
    for maxshift := int64(0); maxshift < N; maxshift++ {
        secs := solve2(N, x, a, maxshift)
        if secs < min {
            min = secs
        }
    }
    return min
}

func main() {
    var N, x int64
    var a []int64

    fmt.Scanf("%d %d\n", &N, &x)
    for i := int64(0); i < N; i++ {
        var v int64
        fmt.Scanf("%d", &v)
        a = append(a, v)
    }
    ans := solve(N, x, a)
    fmt.Printf("%v\n", ans)
}