One way to create a task is to learn from life. You can choose some experience in real life, formalize it and then you will get a new task.

Let's think about a scene in real life: there are lots of people waiting in front of the elevator, each person wants to go to a certain floor. We can formalize it in the following way. We have n people standing on the first floor, the i-th person wants to go to the f_{i}-th floor. Unfortunately, there is only one elevator and its capacity equal to k (that is at most k people can use it simultaneously). Initially the elevator is located on the first floor. The elevator needs |a - b| seconds to move from the a-th floor to the b-th floor (we don't count the time the people need to get on and off the elevator).

What is the minimal number of seconds that is needed to transport all the people to the corresponding floors and then return the elevator to the first floor?


-----Input-----

The first line contains two integers n and k (1 ≤ n, k ≤ 2000) — the number of people and the maximal capacity of the elevator.

The next line contains n integers: f_1, f_2, ..., f_{n} (2 ≤ f_{i} ≤ 2000), where f_{i} denotes the target floor of the i-th person.


-----Output-----

Output a single integer — the minimal time needed to achieve the goal.


-----Examples-----
Input
3 2
2 3 4

Output
8

Input
4 2
50 100 50 100

Output
296

Input
10 3
2 2 2 2 2 2 2 2 2 2

Output
8



-----Note-----

In first sample, an optimal solution is:   The elevator takes up person #1 and person #2.  It goes to the 2nd floor.  Both people go out of the elevator.  The elevator goes back to the 1st floor.  Then the elevator takes up person #3.  And it goes to the 2nd floor.  It picks up person #2.  Then it goes to the 3rd floor.  Person #2 goes out.  Then it goes to the 4th floor, where person #3 goes out.  The elevator goes back to the 1st floor.

Difficulty: interview

Starter code:

Solutions:
"""
Codeforces Contest 270 Problem B

Author  : chaotic_iak
Language: Python 3.3.4
"""

def main():
    n,k = read()
    a = [i-1 for i in read()]
    a.sort()
    a.reverse()
    print(sum(a[::k])*2)

################################### NON-SOLUTION STUFF BELOW

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())

n, k = list(map(int, input().split()))
f = list(map(int, input().split()))

f.sort()
res = 0

while len(f) > 0:
    res += 2 * f[-1] - 2
    for i in range(k):
        if len(f) > 0:
            f.pop()

print(res)


n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
prev = 1
ans = 0
for i, x in enumerate(a):
    t = n - i
    c = (t + k - 1) // k
    v = 2 * c * (x - prev)
    ans += v
    prev = x
print(ans)


n, k = map(int, input().split())
people = list(sorted(map(int, input().split())))
res = 0
while len(people) != 0:
    x = people[-1]
    i = 0
    while len(people) != 0 and i != k:
        i += 1
        people.pop()
    res += x - 1
    res += x - 1
print(res)

n, k = list(map(int, input().split()))
e = 1
ans = 0
p = sorted(list(map(int, input().split())), reverse=True)
for i in range(0, n, k):
    ans += max(p[i:i+k])*2-2
print(ans)


n,k = [int(x) for x in input().split()]
f = [int(x)-1 for x in input().split()]
f.sort()
assert len(f) == n
print(2*sum(f[-1::-k]))


n, k = map(int, input().split())
f = list(map(int, input().split()))
f.sort(reverse = True)
ans = 0
i = 0
while i < n:
    ans += (max(f[i:i+k]) - 1) * 2
    i += k
print(ans)

n,k=list(map(int,input().split()))

L=list(map(int,input().split()))

L.sort(reverse=True)

ans=0
cnt=k
for i in range(n):
    if(cnt==k):
        ans+=2*(L[i]-1)
        cnt=1
    else:
        cnt+=1
print(ans)


n, k = list(map(int, input().split()))
arr = [int(i) for i in input().split()]
ans = [0] * 2001
for i in arr:
    ans[i] += 1
r = 0
j = 2000
while j >= 0:
    z = k
    m = 0
    while z > 0 and j > 0:
        if ans[j] >= z:
            m = max(m, j)
            ans[j] -= z
            z = 0
            break
        z -= ans[j]
        if ans[j] > 0:
            m = max(j, m)
        ans[j] = 0
        j -= 1
    if ans[j] == 0:
        j -= 1
    if m > 1:
        r += 2 * (m - 1)
print(r)


a, b = list(map(int, input().split(' ')))
floors = list(map(int, input().split(' ')))
floors.sort()
floors.reverse()
total = 0
while floors != []:
    if len(floors) >= b: 
        dist = floors[0]-1
        goto = floors[b-1]
        total += (dist + goto-1 + abs(floors[0]-goto))
        floors = floors[b:]
    else:
        dist = floors[0]-1
        total += 2*dist
        floors = []

print(total)


n, k = list(map(int, input().split()))
f = list(map(int, input().split()))
f = sorted(f)
i = 0 
cnt = 0
for i in range(1, n + 1, k):
    cnt += (f[-i] - 1) * 2
print(cnt)
    



n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
ans = 0
for i in range((n - 1) // k + 1):
    ans += (a[i * k] - 1)
print(ans * 2)

import math

#input
n,k=map(int,input().split())
flist=[int(x) for x in input().split()]



#variables
time=0



#main
flist.sort()
flist.reverse()
if n<=k:
	print(2*flist[0]-2)
	quit()

for i in range(math.ceil(n/k)):
	time+=2*flist[k*i]-2

print(time)

[n, k], a, i, ans, t = list(map(int, input().split())), sorted(map(int, input().split())), 0, 0, 1
while i < len(a):
    ans += ((n + k - 1) // k * 2 - 1) * (a[i] - t)
    t = a[i]
    while i < len(a) and a[i] == t:
        i += 1
        n -= 1
print(ans + t - 1)


n, k = map(int, input().split())
f = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in range(0, n, k):
    ans+=2*(f[i]-1)
print(ans)

n, k = map(int,input().split())
f = list(map(int,input().split()))
f.sort(reverse = True)
ans = 0
places = 0
for fl in f:
    places += 1
    if places == 1:
        ans += 2 * (fl - 1)
    if places == k:
        places = 0
print(ans)

n,k = list(map(int,input().split()))
c = 0
a = list(map(int,input().split()))
a.sort()
while(a):
    t = []
    for i in range(k):
        if(a):
            t.append(a.pop())
    c += (max(t)-1)*2
    t.clear()
print(c)
            


input_to_list = lambda: [int(i) for i in input().split()]
n, k = input_to_list()
values = input_to_list()
values.sort()
n -= 1
min_time = 0
while n >= 0:
    min_time += (values[n] - 1) * 2
    n -= k
print(min_time)


n, k = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
ans = 0
p = 1
i = 0
while n != 0:
    tp = arr[i]
    ans += 2 * (tp - p) * (round(n / k + 0.49999999999999))
    while n != 0 and arr[i] == tp:
        n -= 1
        i += 1
    p = tp
print(ans)



n, k = map(int, input().split())
s = list(map(int, input().split()))
s = sorted(s)
m = 0
if len(s)%k!= 0:
    m = 2*(max(s[:len(s)%k]) - 1)
    s = s[len(s)%k:]
while s != []:
    l = len(s)
    m += (s[l-1] - 1)*2
    s = s[:l-k]
print(m)

N, K = map(int, input().split())
F = list(reversed(sorted(map(int, input().split()))))
res = 0
for i in range((N+K-1)//K):
	res += 2 * (F[i*K]-1)
print(res)

import math
import sys
import os

n,k = map(int,input().split())

step = list(map(int,input().split()))


step.sort()
step.reverse()



if n>k:
    z = int(round(n/k+0.5))
    res = 0
    for i in range(z):
        if k<len(step):
            res += 2*(step[0] -1)
            del step[:k]
        else:
            res += 2*(step[0]-1)
else: res = 2*(step[0] -1)
print(res)

'''
Created on Sep 28, 2014

@author: Ismael
'''

n,k = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
s = 0
for i in range(len(A)-1,-1,-k):
    elems = [A[j] for j in range(i,max(-1,i-k),-1)]
    s += 2*(max(elems)-1)
print(s)


l = input().split()
n = int(l[0])
k = int(l[1])

l1 = input().split()
for x in range(n):
    l1[x] = int(l1[x])
l1 = sorted(l1, reverse = True)

c = 0
for x in range(0, n, k):
    c += 2*(l1[x]-1)

print(c)


n, k = list(map(int, input().split(' ')))
tgt = list(map(int, input().split(' ')))
tgt = sorted(tgt)[::-1]
count = 0
i = 0
cap = k
while i < n:
  ref = tgt[i : i + cap]
  if i + cap >= n:
    count += 2 * max(ref) - 2
    break
  i += cap
  count += 2 * max(ref) - 2

print(count)