CodeEff/ECCO huggingface dataset:
# Original solution
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    b = list(map(int, input().rstrip('\n').split()))
    a = [10 ** 10] * n
    for i in range(n-1):
        a[i] = min(b[i], a[i])
        a[i+1] = min(b[i], a[i+1])
    print((sum(a)))


if __name__ == '__main__':
    slove()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    b = list(map(int, readline().split()))
    a = [0] * n
    for i in range(n):
        if i == 0:
            a[i] = b[i]
        elif i == n - 1:
            a[i] = b[i-1]
        else:
            a[i] = min(b[i], b[i-1])
    print((sum(a)))


if __name__ == '__main__':
    solve()
# Original solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(eval(input()))
def getList():
    return list(map(int, input().split()))
import math

n = getN()
INF = 100000000000
nums = [INF] + getList() + [INF]
ans = 0
for i, j in zip(nums, nums[1:]):
    ans += min(i, j)

print(ans)



# Optimized solution
import sys
from collections import defaultdict, deque
import math

# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7

def divide(k):
    return pow(k, MOD-2, MOD)


def make_nck(n):
    ret = [1]
    for i in range(1, n+1):
        ret.append((ret[-1] * (n + 1 - i) * divide(i)) % MOD)

    # print(ret)
    return ret

def make_nigojyo(n):
    ret = [1]

    for i in range(1, n+1):
        ret.append((ret[-1] * 25) % MOD)

    # print(ret)
    return ret


def solve():
    n = getN()
    a = getList()
    ans = 0
    for i, j in zip(a, a[1:]):
        ans += min(i, j)
    ans += a[0] + a[-1]

    print(ans)



def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()
# Original solution
import sys
import math

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(eval(input()))

def finput():
    return float(eval(input()))

def tinput():
    return input().split()

def rinput():
    return list(map(int, tinput()))

def rlinput():
    return list(rinput())

def pro(k, l, n):
    if l < n:
        if k == 0:
            return(n - l)
        return (n - l + 2)
    if l == n:
        if k == 0:
            return 0
        elif k == 1:
            return 1
        return 3
    else:
        l -= n - 1
        if l == k:
            return 1
        elif l > k:
            return 0
        if l < k - 1:
            return 2
        else:
            return 3
            

def rt(k, l , n):
    if k < n:
        if l == 0:
            return (k * 2 + n)
        return (n + k * 2 - 1)
    elif k == n:
        if l == 1:
            return (k * 3 - 2)
        elif l == 0:
            return (k * 3)
        return (k * 3 - 3)
    else:
        k -= n - 1
        if k == l:
            return (n * 3 - 2)
        elif k > l:
            return (n * 3)
        if k < l - 1:
            return ((n - 1) * 3 - 1)
        else:
            return ((n - 1) * 3)



def main():
    n = iinput()
    a = rlinput()
    res = a[0] + a[-1]
    for i in range(n - 2):
        if a[i] > a[i + 1]:
            res += a[i + 1]
        else:
            res += a[i]
    print(res)
    
    
    
    
    


main()



# Optimized solution
A = []
n = int(eval(input()))
B = [1000000] +list(map(int, input().split()))+[1000000]
#print(B)
for i in range(n):
    A += [min(B[i],B[i+1])]
print((sum(A)))
# Original solution
# C
n = int(eval(input()))
b = list(map(int, input().split()))
a = [0 for i in range(n+1)]
a[0] = b[0]
for i in range(n-2):
    a.append(min(b[i], b[i+1]))
a.append(b[-1])
print((sum(a)))

# Optimized solution
n = int(eval(input()))
b = list(map(int, input().split()))
a = [0 for i in range(n+1)]
a[0] = b[0]
for i in range(n-2):
    a.append(min(b[i], b[i+1]))
a.append(b[-1])
print((sum(a)))
# Original solution
N = int(eval(input()))
B = [int(x) for x in input().split()]
A = [0]*N
A[0]   = B[0]
A[N-1] = B[N-2]
for T in range(0,N-2):
    A[T+1] = min(B[T],B[T+1])
print((sum(A)))

# Optimized solution
N = int(eval(input()))
B = [int(x) for x in input().split()]
Sum = B[0]+B[N-2]
for T in range(0,N-2):
    Sum += min(B[T],B[T+1])
print(Sum)
# Original solution
import math

while True:
    try:
        v = eval(input())
        t = v/9.8
        y = v/2*t
        n = math.ceil(y/5.0)+1
        print(int(n))
    except:
        break

# Optimized solution
import math,sys
for e in sys.stdin:
    v=float(e[:-1])
    t=v/9.8
    y=v/2*t
    n=int(math.ceil(y/5))+1
    print(n)
# Original solution
from array import array;
while True:
    n = int(input())
    if n == 0:
        break
    m = int(input())

    s = input()

    cache = array('i', (0 for x in range(m)))

    for i in range(len(s) - 2):
        if s[i:i+3] == 'IOI':
            cache[i + 2] = cache[i] + 1

    print(len([x for x in cache if x >= n]))

# Optimized solution
from array import array;
while True:
    n = int(input())
    if n == 0:
        break
    m = int(input())

    s = input()

    cache = array('i', (0 for x in range(m)))

    for i in range(len(s) - 2):
        if s[i:i+3] == 'IOI':
            cache[i + 2] = cache[i] + 1

    print(sum(1 for x in cache if x >= n))
# Original solution
while 1:
	n=eval(input())
	if n==0:break
	m=eval(input())
	a=input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		for k in range(l):
			if a[i+k]!=P[k]:
				break
		else:c+=1
	print(c)
	

# Optimized solution
while 1:
	n=int(input())
	if n==0:break
	m=int(input())
	a=input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		if a[i:i+l]==P:c+=1
	print(c)
# Original solution
while True:
        n = eval(input())
        if n == 0:
            break
        m = eval(input())
        s = input()
        cur,score = 0,0
        for c in s:
            if cur <= 2*n:
                if cur % 2 == 0:
                    cur = cur+1 if c=="I" else 0
                else:
                    cur = 1 if c=="I" else cur+1
            elif cur == 2*n+1:
                score += 1
                cur = 1 if c=="I" else 2*n
        print(score)

# Optimized solution
while True:
        n = eval(input())
        if n == 0:
            break
        m = eval(input())
        s = input()
        graph = []
        for i in range(n):
            graph.append({"I":2*i+1,"O":0,"score":0})
            graph.append({"I":1,"O":2*(i+1),"score":0})
        graph.append({"I":2*n+1,"O":0,"score":0})
        graph.append({"I":1,"O":2*n,"score":1})
        cur,score = 0,0
        for c in s:
            cur = graph[cur][c]
            score += graph[cur]["score"]
        print(score)
# Original solution
# AOJ 0538: IOIOI
# Python3 2018.7.1 bal4u

while True:
	n = int(eval(input()))
	if n == 0: break
	m = int(eval(input()))
	s = input().strip()
	ans = cnt = i = 0
	while i < m:
		if i+1 < m and s[i:i+2] == 'IO':
			cnt += 1
			i += 1
		elif cnt > 0:
			if s[i] == 'O': cnt -= 1
			if cnt >= n: ans += cnt-n+1
			cnt = 0
		i += 1
	print(ans)



# Optimized solution
# AOJ 0538: IOIOI
# Python3 2018.7.1 bal4u

import sys
from sys import stdin
input = stdin.readline

while True:
	n = int(eval(input()))
	if n == 0: break
	m = int(eval(input()))
	s = input().strip()
	ans = cnt = i = 0
	while i < m:
		if i+1 < m and s[i:i+2] == 'IO':
			cnt += 1
			i += 1
		elif cnt > 0:
			if s[i] == 'O': cnt -= 1
			if cnt >= n: ans += cnt-n+1
			cnt = 0
		i += 1
	print(ans)
# Original solution
#encoding=utf-8

while True:
	x, num = list(map(int,input().split()))
	if x == num == 0:
		break
	count = 0
	for a in range(10):
		if num == a and x == 1:
			count += 1
		if x > 1:
			for b in range(a + 1,10):
				if num == a+b and x == 2:
					count += 1
				if x > 2:
					for c in range(b + 1,10):
						if num == a+b+c and x == 3:
							count += 1
						if x > 3:
							for d in range(c + 1,10):
								if num == a+b+c+d and x == 4:
									count += 1
								if x > 4:
									for e in range(d + 1,10):
										if num == a+b+c+d+e and x == 5:
											count += 1
										if x > 5:
											for f in range(e + 1,10):
												if num == a+b+c+d+e+f and x == 6:
													count += 1
												if x > 6:
													for g in range(f + 1,10):
														if num == a+b+c+d+e+f+g and x == 7:
															count += 1
														if x > 7:
															for h in range(g + 1,10):
																if num == a+b+c+d+e+f+g+h and x == 8:
																	count += 1
																if x > 8:
																	for i in range(h + 1,10):
																		if num == a+b+c+d+e+f+g+h+i and x == 9:
																			count += 1
																			
	print(count)

# Optimized solution
import itertools as iter
while True:
	count = 0
	x,y = list(map(int,input().split()))
	if x == y == 0: break
	for element in iter.combinations(list(range(10)),x):
		if sum(element) == y:
			count += 1
	print(count)
# Original solution
def f2(cnt, n, ci):
    if n < ci:
        return 0
    elif n == ci and cnt > 1:
        return 0
    elif n == ci and cnt == 1:
        return 1
    else:
        v = f2(cnt - 1, n - ci, ci + 1)
        v += f2(cnt, n, ci + 1)
        return v


while 1:
    n, s = list(map(int, input().split()))
    if n == 0 and s == 0:
        break
    print((f2(n, s, 0)))

# Optimized solution
def f2(cnt, n, ci):
    if ci >= 10 or n > 45:
        return 0
    elif n < ci:
        return 0
    elif n == ci and cnt > 1:
        return 0
    elif n == ci and cnt == 1:
        return 1
    else:
        v = f2(cnt - 1, n - ci, ci + 1)
        v += f2(cnt, n, ci + 1)
        return v


while 1:
    n, s = list(map(int, input().split()))
    if n == 0 and s == 0:
        break
    print((f2(n, s, 0)))
# Original solution
def dec2bin(n, base=10):
    s = format(n,'b')
    s = "0"*(10-len(s))+s
    return s
 
x=[[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = dec2bin(i)
    s = 0
    c = B.count("1")
    j = 0
    for e in B:
        if e=="1": s+=j
        j+=1
    x[c][s]+=1

while 1:
    n, s=list(map(int, input().split()))
    if n==0 and s==0: break
    if s>=50: print(0)
    else: print(x[n][s])

# Optimized solution
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s,c = s+j, c+1
        j += 1
    x[c][s]+=1

while 1:
    n, s=list(map(int, input().split()))
    if n==0 and s==0: break
    print(0 if s>=50 else x[n][s])
# Original solution
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
print(((n-2)//(k-1)+1))

# Optimized solution
n,k=list(map(int,input().split()))
print(((n-2)//(k-1)+1))
# Original solution
import sys
import math
N,K=list(map(int,input().split()))
A=[int(i) for i in input().split()]
a=0
for i in range(N):
    if A[i]==1:
        a=i
        break
if a <=K-1:
    print((math.ceil((N-K)/(K-1))+1))
    sys.exit()
if N-K<=a:
    print((math.ceil((N-K)/(K-1))+1))
    sys.exit()
print((math.ceil((N-K)/(K-1))+1))

# Optimized solution
import math
N,K=list(map(int,input().split()))
A=[int(i) for i in input().split()]
print((math.ceil((N-K)/(K-1))+1))
# Original solution
n, k = list(map(int,input().split()))
dat = list(map(int, input().split()))
i = dat.index(1) + 1 # 1originでi個目に1がある
import math

b1 = k # 今1で占有した場所
a1 = 1 # 1にたどり着くまでに必要な個数
a2 = 0
if b1 < i: # もし、iがいまよりも手前にあるなら
    a2 += math.ceil( (i - k) / (k - 1) )
b1 += a2 * (k - 1)
b1 = n if b1 > n else b1 # 1のターンでたどり着いた場所
a3 = math.ceil((n - b1) / (k - 1))
print((a1+a2+a3))

# Optimized solution
import math
n, k = list(map(int,input().split()))
dat = list(map(int, input().split()))
i = dat.index(1) + 1 # 1 origin で i 個目に 1 がある
reach = k # 今1で占有した場所
a = math.ceil((n - reach) / (k - 1))
print((1+a))
# Original solution
# ABC099C - Minimization
from math import ceil

N, K = list(map(int, input().rstrip().split()))
_ = list(map(int, input().rstrip().split()))
print((1 + ceil((N - K) / (K - 1))))

# Optimized solution
# ARC099C - Minimization
from math import ceil

N, K = list(map(int, input().rstrip().split()))
print((1 + ceil((N - K) / (K - 1))))
# Original solution
import math

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

ans = math.ceil((n-1)/(k-1))
print(ans)

# Optimized solution
import math
n, k = list(map(int, input().split()))
al = list(map(int, input().split()))

print((math.ceil((n-1)/(k-1))))
# Original solution
def main():
  n,k = input_list()
  a = input_list()
  ans = 0
  r = 1
  while True:
    r += k-1
    ans += 1
    if r >= n:
      break
  print(ans)
  
def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

# Optimized solution
import math


def main():
    n, k = input_list()
    a = input_list()
    a = math.ceil((n-k)/(k-1))
    print((1+a))


def input_list():
    return list(map(int, input().split()))


if __name__ == "__main__":
    main()
# Original solution
# import sys
# input = sys.stdin.readline
import collections
import itertools

def main():
    n, k = input_list()
    a = input_list()
    if (n - 1) % (k - 1) == 0:
        print(((n-1) // (k-1)))
    else:
        v = (n-1) // (k-1)
        print((v + 1))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


# Optimized solution
# import sys
# input = sys.stdin.readline
import collections
import itertools

def main():
    n, k = input_list()
    a = input_list()
    b = n - 1
    x = k - 1
    ans = b // x
    if b % x == 0:
        print(ans)
    else:
        print((ans + 1))

def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()
# Original solution
#!/usr/bin/env python3
n, k, *a = list(map(int, open(0).read().split()))
print((-(-(n - 1) // (k - 1))))


# Optimized solution
n, k = list(map(int, input().split()))
print((-(-~-n // ~-k)))
# Original solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,K = MI()
A = LI()

print(((N-1+K-2)//(K-1)))


# Optimized solution
import sys
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()

print(((N-1+K-2)//(K-1)))
# Original solution
import collections
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = collections.Counter(A)[min(A)]
print((-(-(N-B)//(K-1))))

# Optimized solution
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
print((-(-(N-1)//(K-1))))
# Original solution
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(N):
  if A[i] == 1:
    loc = i
    break
#print(loc) #locは0index

left = loc
right = N-(loc+1)

ans = left//(K-1) + right//(K-1)
nokori = left%(K-1) + 1 + right%(K-1)
#print(ans,nokori)
if nokori == 1:
  ans += 0
elif nokori <= K:
  ans += 1
else:
  ans += 2
print(ans) 


# Optimized solution
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
n = N-1
k = K-1
ans = (n+k-1)//k
print(ans)
# Original solution
N, K = list(map(int, input().split()))
A = [int(x) for x in input().split()]

n = N - K
if n % (K - 1) == 0:
  ans = 1 + n // (K - 1)
else:
  ans = 2 + n // (K - 1)
print(ans)

# Optimized solution
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
n = N - K
if n % (K - 1) == 0:
  ans = 1 + n // (K - 1)
else:
  ans = 2 + n // (K - 1)
print(ans)
# Original solution
import math
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

assert isinstance(A,list)
a = A.index(1)

print((math.ceil((N-1)/(K-1))))

# Optimized solution
import math
N, K = list(map(int, input().split()))
print((math.ceil((N-1)/(K-1))))
# Original solution
n,k = list(map(int,input().split()))
a = [int(i) for i in input().split()]
ans = (n-1)//(k-1)
if ans == (n-1)/(k-1):
    print(ans)
else:
    print((ans+1))
    

# Optimized solution
n,k = list(map(int,input().split()))
a = [int(i) for i in input().split()]
if (n-1)%(k-1)!=0:
    ans = (n-1)//(k-1)+1
else:
    ans = (n-1)//(k-1)
print(ans)
# Original solution
n, k = list(map(int, input().split()))

if n == k:
    print((1))
else:
    i = 0
    for i, a in enumerate(map(int, input().split())):
        if a == 1:
            break
    left = (i - 1) // (k - 1) + 1
    lr = (k - 1) * left + 1
    print((left + (n - lr - 1) // (k - 1) + 1))


# Optimized solution
n, k = list(map(int, input().split()))
print(((n - 2) // (k - 1) + 1))
# Original solution
n,k,*a=list(map(int,open(0).read().split()))
print((((n-1)-1)//(k-1)+1))

# Optimized solution
n,k=list(map(int,input().split()));print(((~-n-1)//~-k+1))
# Original solution
n, k = list(map(int, input().split()))
a = [int(x) for x in input().split()]
idx = r = 0
while idx < n:
    if idx == 0: idx += k
    else: idx += k - 1
    r += 1
print(r)

# Optimized solution
n, k = list(map(int, input().split()))
a = [int(x) for x in input().split()]
idx = k
r = 1
while idx < n:
    idx += k - 1
    r += 1
print(r)
# Original solution
from math import ceil

N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

if K >= N:
    print((1))
else:
    print((ceil((N-1)/(K-1))))

# Optimized solution
from math import ceil

N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
print((ceil((N-1)/(K-1))))
# Original solution
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

mini = min(A)
idx = N + 1
mid = N / 2

for i, a in enumerate(A):
  if a == mini and abs(idx - mid) > abs(i - mid):
    idx = i

ans = i // (K - 1)
rem = i % (K - 1)
if rem:
  ans += 1
  if (N - i - 1 - (K - rem)) // (K - 1) > 0:
    ans += (N - i - 1 - (K - rem)) // (K - 1)
    if (N - i - 1 - (K - rem)) % (K - 1) != 0:
      ans += 1
else:
  if (N - i - 1) // (K - 1) > 0:
    ans += (N - i - 1) // (K - 1)
    if (N - i - 1) % (K - 1) != 0:
        ans += 1
print(ans)

# Optimized solution
N,K=map(int,input().split())
print((N-1)//(K-1)+1)if(N-1)%(K-1)else print((N-1)//(K-1))
# Original solution
N, K = [int(x) for x in input().split()]
A_lst = [int(x) for x in input().split()]
r = -1
l = -1
for i in range(N):
    if A_lst[i] == 1:
        r = i
        l = N - i - 1
print(((r + l + K - 2)//(K - 1)))


# Optimized solution
N, K = [int(x) for x in input().split()]
print(((N + K - 3)//(K - 1)))
# Original solution
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N, K = list(map(int, input().split()))
    A = [int(a) for a in input().split()]
    l = A.index(1)
    count = 1
    
    r = K - 1
    while r < l:
        r += (K - 1)
        count += 1
    
    if r < N - 1:
        ll = N - K
        count += 1
        while ll > r:
            ll -= (K - 1)
            count += 1
    print(count)
    
    return 0

if __name__ == "__main__":
    solve()

# Optimized solution
import sys

def solve():
    input = sys.stdin.readline
    N, K = list(map(int, input().split()))
    A = [int(a) for a in input().split()]
    mid = A.index(1)
    count = 1
    r = K - 1
    while r < mid:
        r += (K - 1)
        count += 1

    if r < N - 1:
        l = N - K
        count += 1
        while l > r:
            l -= (K - 1)
            count += 1
    print(count)


    return 0

if __name__ == "__main__":
    solve()
# Original solution
import sys
input = sys.stdin.readline

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

idx = a.index(1)

left = idx
right = n - (idx + 1)

ans = 10 ** 10

for i in range(k):
    cnt = 1
    left_ = left - i
    right_ = right - (k - 1 - i)
    cnt += left_//(k - 1) + right_//(k - 1) + int(not left_ % (k - 1) == 0) + int(not right_ % (k - 1) == 0)
    ans = min(ans, cnt)

print(ans)


# Optimized solution
import sys
input = lambda: sys.stdin.readline().rstrip()
 
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
    if a[i] == 1:
        break
left = len(a[:i])
right = len(a[i + 1:])

ans = left // (k - 1) + right//(k - 1) + (left%(k-1) + right%(k-1))//(k-1) + int((left%(k-1) + right%(k-1))%(k - 1) != 0)

print(ans)
# Original solution
from math import ceil
N, K = list(map(int, input().split()))
Alist = list(map(int, input().split()))

print((ceil((N-K)/(K-1))+1))

# Optimized solution
from math import ceil
N, K = list(map(int, input().split()))
Alist = list(map(int, input().split()))

print((ceil((N-1)/(K-1))))
# Original solution
def inpl(): return list(map(int, input().split()))

N, K = inpl()
A = list(inpl())
i = A.index(1)

print((-((K-N)//(K-1)) + 1))

# Optimized solution
N,K=list(map(int,input().split()));print((-((1-N)//(K-1))))
# Original solution
n, k, *_ = list(map(int, open(0).read().split()))
print(((n - 2) // (k - 1) + 1))

# Optimized solution
n, k = list(map(int, open(0).readline().split()))
print(((n - 2) // (k - 1) + 1))
# Original solution
from math import ceil
N,K=list(map(int, input().split()))
A=list(map(int, input().split()))

left=0
right=0
for i in range(N):
  if A[i]==1:
    left=i
    right=N-(i+1)
ans=ceil((left+right)/(K-1))
print(ans)




# Optimized solution
from math import ceil

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
if K==N:
    print((1))
    exit()
print((ceil((N-1)/(K-1))))
# Original solution
import math
N, K, *A = list(map(int, open(0).read().split()))
I = A.index(1)
print((math.ceil((N-1)/(K-1))))

# Optimized solution
N, K = list(map(int, input().split()))
print(((N+K-3)//(K-1)))
# Original solution
import math
n,k = list(map(int, input().split()))
a = list(map(int,input().split()))
for i in range(n):
    if n/(k+((k-1)*i)) <= 1:
        print((i+1))
        break

# Optimized solution
import math
n,k = list(map(int, input().split()))
a = list(map(int,input().split()))
print((math.ceil(((n-k)/(k-1)))+1))
# Original solution
n, k, *a = list(map(int, open(0).read().split()))
mn = min(a)
cnt = sum([1 for x in a if x != mn])
print((0 - - cnt // (k - 1)))


# Optimized solution
n, k, *a = list(map(int, open(0).read().split()))
print((0 - - (n - 1) // (k - 1)))
# Original solution
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
i = A.index(1)
j = K-1
l = i
r = N - l - 1
ans, e = divmod(l, j)
if e:
    ans += 1
    r -= K - e - 1
ans += (r+j-1)//j
print(ans)

# Optimized solution
N,K=list(map(int, input().split()))
*A,=list(map(int, input().split()))

print((((N-1)+(K-1)-1)//(K-1)))
# Original solution
import math
N, K, *A = list(map(int, open(0).read().split()))
print((math.ceil((N-1)/(K-1))))


# Optimized solution
import math
N, K = list(map(int, input().split()))
print((math.ceil((N-1)/(K-1))))