#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ld long double
#define test ll t=0;cin>>t; while(t--)
#define loop(i,a,b) for(i=a;i<=b;i++)
#define loopr(i,a,b) for(i=a;i>=b;i--)
#define lb lower_bound
#define ub upper_bound
#define mid(l,r) mid=l+(r-l)/2
#define endl "\n"
#define yess cout<<"YES\n"
#define noo cout<<"NO\n"


int main()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif
   fastio;
   ll n,k;cin>>n>>k;
   vector<ll>a(n);
   ll i,y=0;
   ll s[1000000]={0};
   ll ans=0;
   for(i=0;i<n;i++)
   {
    cin>>a[i];
    s[a[i]]++;
   }
   for(i=0;i<1e6;)
   {
    if(s[i]==0){
      ans=ans+i;y++;
      if(y==k)break;
     if(i==0)break;
      i=0;continue;

    }
    s[i]--;i++;
   }
   cout<<ans;
    
}

#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
#define ll long long
ll a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r,z,m,h,p[200001],mod=1000000007,mod1=998244353;
string t,x,q,s;
long long df[101];
//double ;
vector<ll>v,u,w;
vector<ll>dv[101];
//vector<string>;
set<ll>y;
map<ll,ll>n;
void dfs(ll x){
    df[x]=1;
    for(ll i=0;i<dv[x].size();i++){
        if(df[dv[x][i]]==0){
            df[dv[x][i]]=1;
            dfs(dv[x][i]);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>a>>b;
    for(i=1;i<=b;i++){
        cin>>p[i];
    }
    d=0;
    e=a+1;
    sort(p+1,p+b+1);
    if(b==0){
        cout<<1;
    }
    else if(b==a){
        cout<<0;
    }
    else{
        if(p[1]>1){
            v.pb(p[1]-1);
        }
        for(i=2;i<=b;i++){
            if(p[i]-1!=p[i-1]){
                v.pb(p[i]-p[i-1]-1);
            }
        }
        if(p[b]<a){
            v.pb(e-p[b]-1);
        }
        sort(v.begin(),v.end());
        d=v[0];
        e=mod;
        for(i=1;i<=d;i++){
            f=0;
            for(j=0;j<v.size();j++){
                f=f+((v[j]+v[0]-1)/v[0]);
            }
            e=min(e,f);
        }
        cout<<e;
    }
}