Public Class Compiler
    Shared Sub Main()
        Dim inputNM As String() = Console.ReadLine().Split(" ")
        Dim n As Integer = Integer.Parse(inputNM(0))
        Dim m As Integer = Integer.Parse(inputNM(1))
        Dim output As Integer = 0
        If n < m Then 
            Dim inputXs As String() = Console.ReadLine().Split(" ")
            Dim xs(0 To m - 1) As Integer
            For i As Integer = 0 To m - 1
                xs(i) = Integer.Parse(inputXs(i))
            Next
            Array.Sort(xs)
            Dim dists(0 To m - 2) As Integer
            For i As Integer = m - 2 To 0 Step -1
                dists(i) = xs(i + 1) - xs(i)
            Next
            Array.Sort(dists)
            Dim l As Integer = 0
            For i As Integer = m - 2 To (m - 2) - (n - 2) Step -1
                l += dists(i)
            Next
            output = xs(m - 1) - xs(0) - l
        End If
        Console.WriteLine(output)
    End Sub
End Class