Under construction

Still being built. Things may change

Gift

Interview

Time limit1sMemory limit1024 MB

Summary
Given the daily sock prices, find the minimum cost to buy X socks on each of two consecutive days, 2X socks in total.
Level

Easy2 of 10

Topics
Array, Implementation
Solved
No attempts yet

Problem

Dongwon's birthday is NN days from now. Let's congratulate him!

Junwon plans to give Dongwon 2X2X socks as a birthday present. He will buy the socks at a market. Over two consecutive days, Junwon buys XX socks each day and loads them into a truck.

Sock prices at the market can differ from day to day. On the ii-th day counting from today, one sock costs AiA_i won.

There are NN days left until Dongwon's birthday. Among those NN days, what is the minimum cost to buy 2X2X socks over two consecutive days?

Input

The first line contains NN and XX, separated by a space.

The second line contains the sock prices A1,A2,⋯ ,ANA_1, A_2, \cdots, A_N for the NN days, separated by spaces.

Output

Print the minimum cost to buy 2X2X socks by buying XX socks per day over two consecutive days.

Constraints

  • 2≤N≤100 0002 \le N \le 100\,000
  • 1≤X≤1 000 0001 \le X \le 1\,000\,000
  • 1≤Ai≤1 0001 \le A_i \le 1\,000 (1≤i≤N1 \le i \le N)

Examples2

  1. Example 1

    Input
    5 10
    9 2 5 7 6
    
    Expected output
    70
    
  2. Example 2

    Input
    7 142857
    22 35 9 12 25 19 10
    
    Expected output
    2999997