#!usr/bin/env python3

from collections import defaultdict

import math

def LI(): return list(map(int, input().split()))

def II(): return int(eval(input()))

def LS(): return input().split()

def S(): return eval(input())

def IIR(n): return [II() for i in range(n)]

def LIR(n): return [LI() for i in range(n)]

def SR(n): return [S() for i in range(n)]

mod = 1000000007



#A

"""

t,x = LI()

print(t/x)

"""



#B

"""

n= II()

a = LI()

m = max(a)

if m >= sum(a)-m:

    print("No")

else:

    print("Yes")

"""



#C

n,m = LI()

x = LI()

x.sort()

l = [x[i+1]-x[i] for i in range(m-1)]

l.sort()

l = l[::-1]

ans = sum(l[max(n-1,0):])

print(ans)

#D

"""

n,k = LI()

a = LI()

l = 0

b = [0 for i in range(n)]

for i in range(n):

    b[i] = list(bin(a[i]))[2:]

    l = max(l,len(b[i]))

s = [0 for i in range(l)]

for i in range(n):

    for j in range(l-len(b[i])):

        b[i].insert(0,"0")

for i in range(n):

    for j in range(l):

        s[j] += 1-int(b[i][j])

ke = 1

for i in range(l)[::-1]:

    if s[i] <= n//2:

        s[i] = [(n-s[i])*ke,0,float("inf")]

    else:

        s[i] = [(n-s[i])*ke,s[i]*ke,ke]

    ke *= 2

s.sort(key = lambda x:x[0])

d = 0

ans = 0

key = len(list(bin(k)))-2

key -= l

ke = 2**l

print(s)

for i in range(key):

    d += ke

    ans += n*ke

    ke *= 2

for i in range(l):

    r,q,p = s[i]

    if d+p <= k:

        d += p

        ans += q

    else:

        ans += r

print(ans)

"""

#E



#F



#G



#H



#I



#J



#K



#L



#M



#N



#O



#P



#Q



#R



#S



#T

#!usr/bin/env python3

from collections import defaultdict

from heapq import heappush, heappop

import sys

import math

import bisect

import random

def LI(): return list(map(int, sys.stdin.readline().split()))

def I(): return int(sys.stdin.readline())

def LS():return list(map(list, sys.stdin.readline().split()))

def S(): return list(sys.stdin.readline())[:-1]

def IR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = I()

    return l

def LIR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = LI()

    return l

def SR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = S()

    return l

def LSR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = SR()

    return l

mod = 1000000007

#A

def A():

    t,x = LI()

    print((t/x))



#B

def B():

    n = I()

    a = LI()

    m = max(a)

    if m >= sum(a)-m:

        print("No")

    else:

        print("Yes")





#C

def C():

    n,m = LI()

    x = LI()

    x.sort()

    l = [x[i+1]-x[i] for i in range(m-1)]

    l.sort()

    l = l[::-1]

    ans = sum(l[max(n-1,0):])

    print(ans)



#D

def D():

    n,k = LI()

    a = LI()

    k = list(map(int,list(bin(k)[2:])))

    l = len(k)

    for i in range(n):

        a[i] = list(map(int,list(bin(a[i])[2:])))

        l = max(l,len(a[i]))

    for i in range(n):

        for j in range(l-len(a[i])):

            a[i].insert(0,0)

    for j in range(l-len(k)):

        k.insert(0,0)

    s = [[0,0] for i in range(l)]

    pow2 = [1 for i in range(l)]

    for i in range(l-1)[::-1]:

        pow2[i] = pow2[i+1]*2

    for i in a:

        for j in range(l):

            s[j][0] += pow2[j]*i[j]

            s[j][1] += pow2[j]*(not i[j])

    dp = [0 for i in range(l+1)]

    small = False

    for i in range(l):

        if not small:

            if not k[i]:

                dp[i+1] += dp[i]+s[i][0]

            else:

                if s[i][0] >= s[i][1]:

                    dp[i+1] += dp[i]+s[i][0]

                    small = True

                else:

                    dp[i+1] += dp[i]+s[i][1]

        else:

            dp[i+1] += dp[i]+max(s[i])

    print((dp[l]))



#E

if __name__ == "__main__":

    C()



#F



#G



#H



#I



#J



#K



#L



#M



#N



#O



#P



#Q



#R



#S



#T

#!usr/bin/env python3
from collections import defaultdict
import math


def LI():
    return list(map(int, input().split()))


def II():
    return int(eval(input()))


def LS():
    return input().split()


def S():
    return eval(input())


def IIR(n):
    return [II() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


mod = 1000000007
# A
"""
t,x = LI()
print(t/x)
"""
# B
"""
n= II()
a = LI()
m = max(a)
if m >= sum(a)-m:
    print("No")
else:
    print("Yes")
"""
# C
n, m = LI()
x = LI()
x.sort()
l = [x[i + 1] - x[i] for i in range(m - 1)]
l.sort()
l = l[::-1]
ans = sum(l[max(n - 1, 0) :])
print(ans)
# D
"""
n,k = LI()
a = LI()
l = 0
b = [0 for i in range(n)]
for i in range(n):
    b[i] = list(bin(a[i]))[2:]
    l = max(l,len(b[i]))
s = [0 for i in range(l)]
for i in range(n):
    for j in range(l-len(b[i])):
        b[i].insert(0,"0")
for i in range(n):
    for j in range(l):
        s[j] += 1-int(b[i][j])
ke = 1
for i in range(l)[::-1]:
    if s[i] <= n//2:
        s[i] = [(n-s[i])*ke,0,float("inf")]
    else:
        s[i] = [(n-s[i])*ke,s[i]*ke,ke]
    ke *= 2
s.sort(key = lambda x:x[0])
d = 0
ans = 0
key = len(list(bin(k)))-2
key -= l
ke = 2**l
print(s)
for i in range(key):
    d += ke
    ans += n*ke
    ke *= 2
for i in range(l):
    r,q,p = s[i]
    if d+p <= k:
        d += p
        ans += q
    else:
        ans += r
print(ans)
"""
# E
# F
# G
# H
# I
# J
# K
# L
# M
# N
# O
# P
# Q
# R
# S
# T

#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random


def LI():
    return list(map(int, sys.stdin.readline().split()))


def I():
    return int(sys.stdin.readline())


def LS():
    return list(map(list, sys.stdin.readline().split()))


def S():
    return list(sys.stdin.readline())[:-1]


def IR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = I()
    return l


def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = LI()
    return l


def SR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = S()
    return l


def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = SR()
    return l


mod = 1000000007
# A
def A():
    t, x = LI()
    print((t / x))


# B
def B():
    n = I()
    a = LI()
    m = max(a)
    if m >= sum(a) - m:
        print("No")
    else:
        print("Yes")


# C
def C():
    n, m = LI()
    x = LI()
    x.sort()
    l = [x[i + 1] - x[i] for i in range(m - 1)]
    l.sort()
    l = l[::-1]
    ans = sum(l[max(n - 1, 0) :])
    print(ans)


# D
def D():
    n, k = LI()
    a = LI()
    k = list(map(int, list(bin(k)[2:])))
    l = len(k)
    for i in range(n):
        a[i] = list(map(int, list(bin(a[i])[2:])))
        l = max(l, len(a[i]))
    for i in range(n):
        for j in range(l - len(a[i])):
            a[i].insert(0, 0)
    for j in range(l - len(k)):
        k.insert(0, 0)
    s = [[0, 0] for i in range(l)]
    pow2 = [1 for i in range(l)]
    for i in range(l - 1)[::-1]:
        pow2[i] = pow2[i + 1] * 2
    for i in a:
        for j in range(l):
            s[j][0] += pow2[j] * i[j]
            s[j][1] += pow2[j] * (not i[j])
    dp = [0 for i in range(l + 1)]
    small = False
    for i in range(l):
        if not small:
            if not k[i]:
                dp[i + 1] += dp[i] + s[i][0]
            else:
                if s[i][0] >= s[i][1]:
                    dp[i + 1] += dp[i] + s[i][0]
                    small = True
                else:
                    dp[i + 1] += dp[i] + s[i][1]
        else:
            dp[i + 1] += dp[i] + max(s[i])
    print((dp[l]))


# E
if __name__ == "__main__":
    C()
# F
# G
# H
# I
# J
# K
# L
# M
# N
# O
# P
# Q
# R
# S
# T

+from heapq import heappush, heappop +import sys +import bisect +import random -    return list(map(int, input().split())) +    return list(map(int, sys.stdin.readline().split())) -def II(): -    return int(eval(input())) +def I(): +    return int(sys.stdin.readline()) -    return input().split() +    return list(map(list, sys.stdin.readline().split())) -    return eval(input()) +    return list(sys.stdin.readline())[:-1] -def IIR(n): -    return [II() for i in range(n)] +def IR(n): +    l = [None for i in range(n)] +    for i in range(n): +        l[i] = I() +    return l -    return [LI() for i in range(n)] +    l = [None for i in range(n)] +    for i in range(n): +        l[i] = LI() +    return l -    return [S() for i in range(n)] +    l = [None for i in range(n)] +    for i in range(n): +        l[i] = S() +    return l + + +def LSR(n): +    l = [None for i in range(n)] +    for i in range(n): +        l[i] = SR() +    return l -""" -t,x = LI() -print(t/x) -""" +def A(): +    t, x = LI() +    print((t / x)) + + -""" -n= II() -a = LI() -m = max(a) -if m >= sum(a)-m: -    print("No") -else: -    print("Yes") -""" +def B(): +    n = I() +    a = LI() +    m = max(a) +    if m >= sum(a) - m: +        print("No") +    else: +        print("Yes") + + -n, m = LI() -x = LI() -x.sort() -l = [x[i + 1] - x[i] for i in range(m - 1)] -l.sort() -l = l[::-1] -ans = sum(l[max(n - 1, 0) :]) -print(ans) +def C(): +    n, m = LI() +    x = LI() +    x.sort() +    l = [x[i + 1] - x[i] for i in range(m - 1)] +    l.sort() +    l = l[::-1] +    ans = sum(l[max(n - 1, 0) :]) +    print(ans) + + -""" -n,k = LI() -a = LI() -l = 0 -b = [0 for i in range(n)] -for i in range(n): -    b[i] = list(bin(a[i]))[2:] -    l = max(l,len(b[i])) -s = [0 for i in range(l)] -for i in range(n): -    for j in range(l-len(b[i])): -        b[i].insert(0,"0") -for i in range(n): -    for j in range(l): -        s[j] += 1-int(b[i][j]) -ke = 1 -for i in range(l)[::-1]: -    if s[i] <= n//2: -        s[i] = [(n-s[i])*ke,0,float("inf")] -    else: -        s[i] = [(n-s[i])*ke,s[i]*ke,ke] -    ke *= 2 -s.sort(key = lambda x:x[0]) -d = 0 -ans = 0 -key = len(list(bin(k)))-2 -key -= l -ke = 2**l -print(s) -for i in range(key): -    d += ke -    ans += n*ke -    ke *= 2 -for i in range(l): -    r,q,p = s[i] -    if d+p <= k: -        d += p -        ans += q -    else: -        ans += r -print(ans) -""" +def D(): +    n, k = LI() +    a = LI() +    k = list(map(int, list(bin(k)[2:]))) +    l = len(k) +    for i in range(n): +        a[i] = list(map(int, list(bin(a[i])[2:]))) +        l = max(l, len(a[i])) +    for i in range(n): +        for j in range(l - len(a[i])): +            a[i].insert(0, 0) +    for j in range(l - len(k)): +        k.insert(0, 0) +    s = [[0, 0] for i in range(l)] +    pow2 = [1 for i in range(l)] +    for i in range(l - 1)[::-1]: +        pow2[i] = pow2[i + 1] * 2 +    for i in a: +        for j in range(l): +            s[j][0] += pow2[j] * i[j] +            s[j][1] += pow2[j] * (not i[j]) +    dp = [0 for i in range(l + 1)] +    small = False +    for i in range(l): +        if not small: +            if not k[i]: +                dp[i + 1] += dp[i] + s[i][0] +            else: +                if s[i][0] >= s[i][1]: +                    dp[i + 1] += dp[i] + s[i][0] +                    small = True +                else: +                    dp[i + 1] += dp[i] + s[i][1] +        else: +            dp[i + 1] += dp[i] + max(s[i]) +    print((dp[l])) + + +if __name__ == "__main__": +    C()