Buggy python submission (verdict: Runtime Error):
l = input().split(" ")
j = input().split(" ")
k = int(l[0])
n = int(l[1])
x = 0
for i in range(n):
  d = int(j[i+1]) - int(j[i])
  x = max(x,d)
dt = k - int(x)
print(dt)


Fixed submission:
KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []

for home in Al:
  A.append(int(home))

m = A[0]+(K-A[-1])
 
for i in range(N-1):
  m = max(m,abs(A[i]-A[i+1]))

print(K-m)

Buggy python submission (verdict: Runtime Error):
l = input().split(" ")
j = input().split(" ")
k = int(l[0])
n = int(l[1])
for i in range(n-1):
  d1 = int(j[i+1]) - int(j[i])
  d2 = int(j[i+2]) - int(j[i+1])
  max = max(d1,d2)
dt = k - int(max)
print(dt)


Fixed submission:
KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []

for home in Al:
  A.append(int(home))

m = A[0]+(K-A[-1])
 
for i in range(N-1):
  m = max(m,abs(A[i]-A[i+1]))

print(K-m)

Buggy python submission (verdict: Runtime Error):
l = input().split(" ")
j = input().split(" ")
k = int(l[0])
n = int(l[1])
for i in range(n-1):
  d1 = int(j[i+1]) - int(j[i])
  d2 = int(j[i+2]) - int(j[i+1])
  max = max(d1,d2)
  dt = k - int(max)
print(dt)


Fixed submission:
KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []

for home in Al:
  A.append(int(home))

m = A[0]+(K-A[-1])
 
for i in range(N-1):
  m = max(m,abs(A[i]-A[i+1]))

print(K-m)

Buggy python submission (verdict: Runtime Error):
l = input().split(" ")
j = input().split(" ")
k = int(l[0])
n = int(l[1])
for i in range(j):
  d1 = j[i+1] - j[i]
  d2 = j[i+2] - j[i+1]
  max = max(d1,d2)
  dt = k - int(max)
print(dt)


Fixed submission:
KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []

for home in Al:
  A.append(int(home))

m = A[0]+(K-A[-1])
 
for i in range(N-1):
  m = max(m,abs(A[i]-A[i+1]))

print(K-m)

Buggy python submission (verdict: Runtime Error):
l = input().split(" ")
j = input().split(" ")
k = int(m[0])
n = int(m[1])
for i in range(j):
  d1 = j[i+1] - j[i]
  d2 = j[i+2] - j[i+1]
  max = max(d1,d2)
  dt = k - int(max)
print(dt)


Fixed submission:
KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []

for home in Al:
  A.append(int(home))

m = A[0]+(K-A[-1])
 
for i in range(N-1):
  m = max(m,abs(A[i]-A[i+1]))

print(K-m)

Buggy python submission (verdict: Runtime Error):
l = input().split(" ")
j = input().split(" ")
k = int(m[0])
n = int(m[1])
A = []
for i in range(j):
  d1 = j[i+1] - j[i]
  d2 = j[i+2] - j[i+1]
  min = min(d1,d2)
  A.append(int(min))
print(A)

Fixed submission:
KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []

for home in Al:
  A.append(int(home))

m = A[0]+(K-A[-1])
 
for i in range(N-1):
  m = max(m,abs(A[i]-A[i+1]))

print(K-m)

Buggy python submission (verdict: Runtime Error):
KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []
for home in Al:
  A.append(int(home))
m = 0

m = distance(A[0],A[-1],M,K)

for i in range(N-1):
  m = max(m,distance(A[i],A[i+1],M,L))
print (10-m)

def distance(d1,d2,M,K):
  if d1<=M and d2<=M:
    return abs(d2-d1)
  if d1<=M and d2>=M:
    return d1+(K-d2)
  if d1>=M and d2>=M:
    return abs(d2-d1)

Fixed submission:
KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []

for home in Al:
  A.append(int(home))

m = A[0]+(K-A[-1])
 
for i in range(N-1):
  m = max(m,abs(A[i]-A[i+1]))

print(K-m)