Buggy python submission (verdict: Time Limit Exceeded):
n,m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()
else:
    difference = []
    x.sort()
 
    for i in range(m-1):
        difference.append(x[i+1]-x[i])
 
    for i in range(n-1):
        difference.remove(max(difference))
 
    print(sum(difference))


Fixed submission:
n,m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()
else:
    difference = []
    x.sort()
 
    for i in range(m-1):
        difference.append(x[i+1]-x[i])
 
    difference.sort()
 
    print(sum(difference[:m-n]))

Buggy python submission (verdict: Runtime Error):
n,m = input().split()
n = int(n)
m = int(m)
 
row_x = input().split()
for i in range(m):
    row_x[i] = int(row_x[i])
 
if n >= m:
    print(0)
else:
    difference = 0
    maximun = []
    x = sorted(row_x)
 
    for i in range(m-1):
        diffe = x[i+1]-x[i]
        difference += diffe
        if len(maximun) < (n-1):
            maximun.append(diffe)
        elif min(maximun) < diffe:
            maximun.append(diffe)  
            maximun.remove(min(maximun))
                     

    print(difference-sum(maximun))

Fixed submission:
n,m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()
else:
    difference = []
    x.sort()
 
    for i in range(m-1):
        difference.append(x[i+1]-x[i])
 
    difference.sort()
 
    print(sum(difference[:m-n]))

Buggy python submission (verdict: Runtime Error):
n,m = input().split()
n = int(n)
m = int(m)
 
row_x = input().split()
for i in range(m):
    row_x[i] = int(row_x[i])
 
if n >= m:
    print(0)
else:
    difference = []
    maximun = []
    x = sorted(row_x)
 
    for i in range(m-1):
        diffe = x[i+1]-x[i]
        difference.append(diffe)
        if len(maximun) < (n-1):
            maximun.append(diffe)
        elif min(maximun) < diffe:
            maximun.remove(min(maximun))
            maximun.append(diffe)           

    print(sum(difference)-sum(maximun))

Fixed submission:
n,m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()
else:
    difference = []
    x.sort()
 
    for i in range(m-1):
        difference.append(x[i+1]-x[i])
 
    difference.sort()
 
    print(sum(difference[:m-n]))

Buggy python submission (verdict: Runtime Error):
n,m = input().split()
n = int(n)
m = int(m)

row_x = input().split()

if n >= m:
    print(0)
else:
    difference = []
    x = sorted(row_x)

    for i in range(m-1):
        difference.append(x[i+1]-x[i])

    for i in range(n-1):
        difference.remove(max(difference))

    print(sum(difference))

Fixed submission:
n,m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()
else:
    difference = []
    x.sort()
 
    for i in range(m-1):
        difference.append(x[i+1]-x[i])
 
    difference.sort()
 
    print(sum(difference[:m-n]))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = input().split()
n = int(n)
m = int(m)

row_x = input().split()
for i in range(m):
    row_x[i] = int(row_x[i])

if n >= m:
    print(0)
else:
    difference = []
    x = sorted(row_x)

    for i in range(m-1):
        difference.append(x[i+1]-x[i])

    for i in range(n-1):
        difference.remove(max(difference))

    print(sum(difference))

Fixed submission:
n,m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()
else:
    difference = []
    x.sort()
 
    for i in range(m-1):
        difference.append(x[i+1]-x[i])
 
    difference.sort()
 
    print(sum(difference[:m-n]))