Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
count = 0
for i in A:
  count += 1
  if count != N:
    B[i]=A[i+1]-A[i]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))


Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
count = 0
for i in A:
  count += 1
  if count < N:
    B[i]=A[i+1]-A[i]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))


Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
for i in range[0, N-1]:
  if i < N-1:
    B[i]=A[i+1]-A[i]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))


Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
for i in A if i < N-1:
  B[i]=A[i+1]-A[i]

B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
for i in A:
  B[i]=A[i+1]-A[i]
  
B[N-1]=A[0]+K-A[N-1]

print(K-max(B))


Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [A[i+1]-A[i] for i in A if i < N]
B[N-1]=A[0]+K-A[N-1]

print(K-max(B))

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = []
while all(a< N-1 for a in A):
  B.append(A[a+1]-A[a])

B.append(A[1]+K-A[a])

print(K-max(B))

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a in A:
  if a < N:
    B.append(A[a+1]-A[a])
  else:
    B.append(A[1]+K-A[a])

print(K-max(B))

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))