#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int n,k;
  cin>>n>>k;
  int a[100000];
  int x,y,z=0,count=0;
  cin>>x;
  count-=x;
  lp(i,n-1){
    cin>>y;
    a[i]=y-(x+1);
    if(a[i]<0){
      z+=a[i];
    }
    x=y;
  }
  count+=x;
  sort(a,a+n-1);
  reverse(a,a+n-1);
  int ans;
  ans=count-z+1;
  lp(i,k-1){
    if(a[i]>0)
    ans-=a[i];
  }
  cout<<ans<<endl;
  
  return 0;
}

