Buggy python submission (verdict: Runtime Error):
K, N = list(map(int, input().srtip().split()))
As = list(map(int, input().strip().split()))
 
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
 
diffs.append(As[0]+K-As[-1])
 
print(K-max(diffs))

Fixed submission:
K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
diffs.append(As[0]+K-As[-1])
print(K-max(diffs))

Buggy python submission (verdict: Runtime Error):
K, N = list(map(int, input().srtip().split()))
As = list(map(int, input().strip().split()))
 
diffs =[]
for base, switch in zip(arr[:-1], arr[1:]):
  diffs.append(switch-base)

diffs.append(arr[0]+K-arr[-1])
 
print(K-max(diffs))

Fixed submission:
K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
diffs.append(As[0]+K-As[-1])
print(K-max(diffs))

Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stsin.readlines()
K, N = list(map(int, lines[0].srtip().split()))
As = list(map(int, lines[1].strip().split()))
 
diffs =[]
for base, switch in zip(arr[:-1], arr[1:]):
  diffs.append(switch-base)

diffs.append(arr[0]+K-arr[-1])
 
print(K-max(diffs))

Fixed submission:
K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
diffs.append(As[0]+K-As[-1])
print(K-max(diffs))

Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stsin.readlines()
K, N = list(map(int, lines[0].srtip().split()))
As = list(map(int, lines[1].strip().split()))

diffs =[]
for base, switch in zip(arr[:-1], arr[1:]):
  diffs.append(switch-base)

diffs.append(arr[0]+K-arr[-1])

print(K-max(diffs))

Fixed submission:
K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
diffs.append(As[0]+K-As[-1])
print(K-max(diffs))

Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stsin.readlines()
K, N = map(int, lines[0].srtip().split())
As = map(int, lines[1].strip().split())

diffs =[]
for base, switch in zip(arr[:-1], arr[1:]):
  diffs append(switch-base)

diffs append(arr[0]+K-arr[-1])

print(K-max(diffs))

Fixed submission:
K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
diffs.append(As[0]+K-As[-1])
print(K-max(diffs))

Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stsin.readlines()
K, N = map(int, lines[0].srtip().split())
As = map(int, lines[1].strip().split())

diffs =[]
for base, switch in zip(arr[:-1], arr[1:]+[0]):
  diffs append(switch-base)

diffs append(arr[0]+K-arr[-1])

print(K-max(diffs))

Fixed submission:
K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
diffs.append(As[0]+K-As[-1])
print(K-max(diffs))

Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stsin.readlines()
K, N = map(int, lines[0].srtip().split())
As = map(int, lines[1].strip().split())

range = max(As)-min(As)

if range*2<K:
  print(range)
else:
  print(K-range)

Fixed submission:
K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
diffs.append(As[0]+K-As[-1])
print(K-max(diffs))