#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,m,*x=map(int,open(0).read().split());x.sort();print(sum(sorted(j-i for i,j in zip(x,x[1:]))[-n::-1]))\n"
"\"";
  system(s);
  return 0;
}            