namespace C
{
    //begin using
    using System;
    using System.Text;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Globalization;
    using System.Numerics;

    //end using 

    class Solver
    {
        long[] x;
        long n, m;
        public void Solve()
        {
            n = cin.NextLong();
            m = cin.NextLong();
            x = new long[m];
            for (int i = 0; i < m; i++)
            {
                x[i] = cin.NextLong();
            }

            Array.Sort(x);
            var d = new long[m - 1];
            for (int i = 0; i < m - 1; i++)
            {
                d[i] = x[i + 1] - x[i];
            }
            Array.Sort(d);
            long ans = 0;
            for (int i = 0; i < m - n; i++)
            {
                ans += d[i];
            }
            Console.WriteLine(ans);
        }

        static Scanner<Stream> cin = new Scanner<Stream>(Console.OpenStandardInput());
        static Printer cout = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
        public static void Main(string[] args)
        {
            //var file = new Scanner<FileStream>(new FileStream("temp.txt", FileMode.Append));
            Console.SetOut(cout);
            new Solver().Solve();
            Console.Out.Flush();
        }
    }

    //begin auxiliary class
    public class Scanner<T>
    where T : Stream
    {
        public Scanner(T stream) { str = stream; }
        private readonly T str;
        private byte[] buf = new byte[1024];
        private int len, itr;
        public bool isEof = false;
        // public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) throw new EndOfStreamException();
            if (itr >= len)
            {
                itr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0)
                {
                    isEof = true;
                    return 0;
                }
            }
            return buf[itr++];
        }
        public char NextChar()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        public string NextString()
        {
            var sb = new StringBuilder();
            char c = NextChar();
            while (c >= 33 && c <= 126) { sb.Append(c); c = (char)read(); }
            return sb.ToString();
        }
        public long NextLong()
        {
            long ret = 0; byte b = 0; var negative = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { negative = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return negative ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int NextInt() { return (int)NextLong(); }
        public ulong NextUlong() { return ulong.Parse(NextString()); }
        public double NextDouble() { return double.Parse(NextString(), CultureInfo.InvariantCulture); }
        public decimal NextDecimal() { return decimal.Parse(NextString()); }
    }
    class Printer : StreamWriter
    {
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
    }
    //end auxiliary class
}


Measured memory_bytes: 12768