#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n,k; cin>>n>>k; vector A(n); rep(i,n) cin>>A[i]; sort(ALL(A)); reverse(ALL(A)); vector B(n-1); rep(i,n-1) B[i]=A[i]-A[i+1]; sort(ALL(B)); reverse(ALL(B)); ll sum=0; rep(i,k-1) sum+=B[i]; cout<