Buggy python submission (verdict: Runtime Error):
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

c = a[0] + (k - a[n - 1])

d = max(c,[a[i] - a[i - 1] for i in range(1, n)])

print(k - d)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

c = a[0] + (k - a[n-1])

c = max(c,[a[i]-a[i-1] for i in range(1,n)])

print(k-c)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

b = a[0] + (k - a[n-1])

c = [a[i]-a[i-1] for i in range(1,n)]

d = max(b,c)

print(d)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

b = a[0] + (k - a[n-1])

c = [a[i]-a[i-1] for i in range(1,n)]

print(max(b,c))


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

c = a[0] + (K - a[n-1])

for i in range(1,N):
    d = max(c, A[i] - A[i-1])

print(K - d)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K,N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

c = A[0]+(K-A[N-1])

for i in range(1,N+1):
    d = max(c,A[i]-A[i-1])

print(K-d)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K,N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

c = A[0]+(K-A[N-1])

for i in range(1,N):
    d = max(d,A[i]-A[i-1])

print(K-d)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K, N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

b = A[0]+(K-A[N-1])

for i in range(1,N):
    a = max(A[i]-A[i-1])

c = max(a,b)

print(K-c)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K, N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

b = A[0]+(K-A[N-1])

a = [A[i]-A[i-1] for i in range(1,N)]

c = max(a,b)

print(K-c)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K, N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

a = [A[i]-A[i-1] for i in range(1,N)]

b = A[0]+(K-A[N-1])

c = max(a,b)

print(K-c)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K, N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

a = [A[i]-A[i-1] for i in range(1,N)]

b = A[0]+(K-A[N-1])

c = max(a,b)

print(K-c)


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K, N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

a = [A[i]-A[i-1] for i in range(1,N-1)]

b = A[0]+(K-A[N-1])

print(K-max(a,b))


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))

dif = [A[i+1]-A[i] for i in range(N-1)]

dif.extend([K-A[N]])

print(K-max(dif))


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))

dif = [A[i+1]-A[i] for i in range(N)]

dif.extend([K-A[N]])

print(K-max(dif))


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
    dif = A[i+1]-A[i]

dif.extend([K-A[N]])

print(K-max(dif))

Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)

Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))

for i in range[N]:
    dif = A[i+1]-A[i]

dif.extend([K-A[N]])

print(K-max(dif))


Fixed submission:
k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)