using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static ABC.Cin;
using static ABC.Cout;
using static ABC.Tool;


namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            Scanf(out int n, out int m);
            var x = ReadSplitInt.ToList();
            x.Sort();
            if(n >= m)
            {
                OutL(0);
                return;
            }
            var dif = new List<int>();
            for(int i = 0; i < m - 1; i++)
            {
                dif.Add(x[i + 1] - x[i]);
            }
            dif.Sort();
            dif.Reverse();

            var ans = x.Max() - x.Min();
            for(int i = 0; i < n - 1; i++)
            {
                ans -= dif[i];
            }
            OutL(ans);
        }
    }

    static class Cin
    {
        public static string[] ReadSplit => Console.ReadLine().Split();
        public static int[] ReadSplitInt => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadSplitLong => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string Str => Console.ReadLine();
        public static int Int => int.Parse(Console.ReadLine());
        public static long Long => long.Parse(Console.ReadLine());
        public static double Double => double.Parse(Console.ReadLine());
        public static T Conv<T>(string input)
        {
            return (T)Convert.ChangeType(input, typeof(T));
        }
        public static void Scanf<T>(out T a) => a = Conv<T>(Console.ReadLine());
        public static void Scanf<T,U>(out T a, out U b)
        {
            var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]);
        }
        public static void Scanf<T, U, V>(out T a, out U b, out V c)
        {
            var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]);
        }
        public static void Scanf<T, U, V, W>(out T a, out U b, out V c, out W d)
        {
            var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]); d = Conv<W>(q[3]);
        }
    }
    static class Cout
    {
        public static void OutL(object s) => Console.WriteLine(s);
    }
    static class Tool
    {
        public static long Gcd(long a, long b)
        {
            if (a % b == 0)
            {
                return b;
            }
            else
            {
                return Gcd(b, a % b);
            }
        }
        public static long Lcm(long a, long b) => a * b / Gcd(a, b);

        public static long[] PrimeFac(long n)
        {
            var result = new long[n + 1];
            for(int i = 2; i * i <= n; i++)
            {
                if (n % i != 0)
                {
                    continue;
                }

                var cnt = 0;
                while(n % i == 0)
                {
                    cnt++;
                    n /= i;
                }
                result[i] = cnt;
            }
            if(n != 1)
            {
                result[n] = 1;
            }
            return result;
        }
        public static long DivsCnt(long n)
        {
            var result = 1L;
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i != 0)
                {
                    continue;
                }

                var cnt = 0;
                while (n % i == 0)
                {
                    cnt++;
                    n /= i;
                }
                result *= (cnt + 1);
            }
            if (n != 1)
            {
                result *= 2;
            }
            return result;
        }

        public static string Reversed(string s)
        {
            return string.Join("", s.Reverse());
        }
    }
}

Measured memory_bytes: 37392