#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 50;
int a[N];
int main()
{
    int n, m;
    ll ans = 0;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
        scanf("%d", a + i);
    sort(a, a + m);
    for (int i = 1; i < m; i++)
        a[i - 1] = a[i] - a[i - 1];
    sort(a, a + m - 1, greater<int>());
    for (int i = n - 1; i < m - 1; i++)
        ans += a[i];
    printf("%lld", ans);
    return 0;
}