#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include<set>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//ABC117-C
int main() {
	ll N;
	scanf("%lld", &N);
	ll M;
	scanf("%lld", &M);
	vector<ll> X(M);
	for (ll i = 0; i < M; i++) {
		scanf("%lld", &X[i]);
	}

	if (M <= N) {
		printf("0\n");
		return 0;
	}

	sort(X.begin(), X.end());

	vector<ll> d;
	for (ll i = 0; i < M - 1; i++) {
		d.push_back(X[i + 1] - X[i]);
	}

	sort(d.begin(), d.end(), std::greater<ll>());

	ll result = X[M - 1] - X[0];

	for (ll i = 0; i < N - 1; i++) {
		result -= d[i];
	}

	printf("%lld\n", result);
}


//ABC065
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll M;
	scanf("%lld", &M);

	if (abs(N - M) >= 2) {
		printf("0\n");
		return 0;
	}

	ll result = 1;
	for (ll i = 1; i <= N; i++) {
		result *= i;
		result %= MOD;
	}
	for (ll i = 1; i <= M; i++) {
		result *= i;
		result %= MOD;
	}

	if (N == M) {
		result *= 2;
		result %= MOD;
	}

	printf("%lld\n", result);
}
*/

//AGC032-A
/*
int main() {
	int ret_scanf;

	ll N;
	ret_scanf = scanf("%lld", &N);
	vector<ll> b(N);
	for (ll i = 0; i < N; i++) {
		ret_scanf = scanf("%lld", &b[i]);
	}

	stack<ll> st;
	bool success = true;
	while (b.size() > 0) {
		bool fail = true;
		for (ll i = b.size() - 1; i >= 0; i--) {
			if (b[i] == i + 1) {
				st.push(i + 1);
				b.erase(b.begin() + i);
				fail = false;
				break;
			}
		}

		if (fail == true) {
			success = false;
			break;
		}
	}

	if (success == true) {
		while (st.empty() == false) {
			ll result = st.top();
			st.pop();
			printf("%lld\n", result);
		}
	}
	else {
		printf("-1\n");
	}

}
*/

//ABC078-C
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll M;
	scanf("%lld", &M);

	ll time_one = M * 1900ll + (N - M) * 100ll;

	ll result = time_one << M;

	printf("%lld\n", result);
}
*/

//AGC008-A
/*
int main() {
	ll x;
	scanf("%lld", &x);
	ll y;
	scanf("%lld", &y);
	
	ll result = INF;


	if (x == y) {
		result = 0;
	}
	else if (x < y) {
		if (x >= 0 && y >= 0) {
			result = y - x;
		}
		else if (x <= 0 && y <= 0) {
			result = y - x;
		}
		else {
			//x:- y:+

			if (abs(x) <= y) {
				result = 1ll + y - abs(x);
			}
			else if (abs(x) > y) {
				result = abs(x) - y + 1ll;
			}
		}
	}
	else if(x > y){
		if (x == 0) {
			result = abs(y) + 1ll;
		}
		else if (y == 0) {
			result = 1ll + x;
		}
		else if (x > 0 && y >= 0) {
			result = 1ll + x - y + 1ll;
		}
		else if (x < 0 && y <= 0) {
			result = 1ll + abs(y) - abs(x) + 1ll;
		}
		else {
			//x:+ y:-

			if (x >= abs(y)) {
				result = 1ll + x - abs(y);
			}
			else if(x < abs(y)) {
				result = abs(y) - x + 1ll;
			}
		}
	}

	printf("%lld\n", result);
}
*/


//ABC097-C
/*
int main() {
	string s;
	cin >> s;
	ll K;
	cin >> K;

	ll len = s.length();
	set<string> st;

	for (ll i = 0; i < len; i++) {
		for (ll j = 1; j <= min(K, len - i); j++) {
			st.insert(s.substr(i, j));
		}
	}

	vector<string> A;
	for (auto item : st) {
		A.push_back(item);
	}

	std::sort(A.begin(), A.end());

	cout << A[K - 1];

}
*/


//ABC99-C
/*
int main() {
	ll N;
	scanf("%lld", &N);

	vector<ll> dp(N + 1, INF);
	dp[N] = 0;

	for (ll i = N; i > 0; i--) {
		if (dp[i] == INF) {
			continue;
		}

		dp[i - 1] = min(dp[i - 1], dp[i] + 1);

		ll draw = 6;
		while (true) {
			if (i >= draw) {
				dp[i - draw] = min(dp[i - draw], dp[i] + 1);
			}
			else {
				break;
			}

			draw *= 6;
		}

		draw = 9;
		while (true) {
			if (i >= draw) {
				dp[i - draw] = min(dp[i - draw], dp[i] + 1);
			}
			else {
				break;
			}

			draw *= 9;
		}
	}

	printf("%lld\n", dp[0]);
}
*/

//ARC100-C
//L1�����̑��a���ŏ�������ɂ͒����l
/*
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N, 0);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}

	vector<ll> B(N, 0);
	ll sum = 0;
	for (ll i = 0; i < N; i++) {
		B[i] = A[i] - (i + 1);
	}

	std::sort(B.begin(), B.end());

	ll b = B[N / 2];


	ll result = 0;

	for (ll i = 0; i < N; i++) {
		result += std::abs(A[i] - (b + i + 1));
	}

	printf("%lld\n", result);
}
*/

Measured memory_bytes: 2168