Under construction

Still being built. Things may change

Lecture Rooms

Interview

Time limit1sMemory limit1024 MB

Summary
Given N lecture room positions on a line and at most K teleports from x=0, find the minimum walking time to visit every room.
Level

Medium6 of 10

Topics
Greedy, Sorting, Heap
Solved
No attempts yet

Problem

Hyeokjun has to attend NN lectures today. Every lecture is held in a lecture room at a different coordinate on the xx-axis. The ii-th lecture room is at x=Aix = A_i, and Hyeokjun starts at x=0x = 0. Each move of 1 to the left or right along the xx-axis takes 11 second. Hyeokjun is a novice wizard and can teleport at most KK times. A teleport moves him instantly from his current position to any other position he chooses, and it takes no time. Find the minimum time for Hyeokjun to start at x=0x = 0 and visit every lecture room once. Attending a lecture takes no time.

Input

The first line contains integers NN and KK. (1≤N≤100 0001 \le N \le 100\,000; 0≤K≤N0 \le K \le N)

The next line contains the distinct integers AiA_i that give the positions of the lecture rooms, separated by spaces. (1≤Ai≤1091 \le A_i \le 10^{9})

Output

Print the minimum time for Hyeokjun to visit every lecture room once.

Examples1

  1. Example 1

    Input
    6 3
    4 9 1 14 5 6
    
    Expected output
    3