#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, m, x[100000];
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
		scanf("%d", x + i);
	sort(x, x + m);
	for (int i = 0; i + 1 < m; i++)
		x[i] = x[i + 1] - x[i];
	sort(x, x + m - 1);
	int cost = 0;
	for (int i = 0; n + i < m; i++)
		cost += x[i];
	printf("%d\n", cost);
}