#include<iostream>
#include<algorithm>
using namespace std;

void search(void);

int time1[100000];
int time2[100000];
int n,k,sub;
int ans;

int main(void){
	
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>time1[i];
	}
	
	ans=n;
	sub=n-k;
	
	search();
	
	sort(time2,time2+n-1);
	
	for(int i=0;i<sub;i++){
		ans+=time2[i];
	}
	
	cout<<ans<<endl;
	return 0;

}
void search(void){
	
	for(int i=0;i<n-1;i++){
		time2[i]=time1[i+1]-time1[i]-1;
	}

}
