#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
const int N=200000+5;
int n,k;
int a[N];
int main(){
freopen ("ntarsis_set.in","r",stdin);
freopen ("ntarsis_set.out","w",stdout);
scanf("%d%d",&n,&k);
for (int i=1;i<=n;i++)scanf("%d",&a[i]);
ll cur=1;
for (int i=1,j=1;i<=k;i++){
while(j<=n&&a[j]-j<cur)j++;
cur+=j-1;
}
printf("%lld\n",cur);
return 0;
}