#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
int n,k;
long long a[N],s;
long long ans;
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("%lld",&a[i]);
if(a[1] > 1){
printf("1\n");
return 0;
}
int l = 2;ans = 1;
for(int i = 1;i <= k;i++){
while(ans + (l-1) >= a[l] && l <= n)l++;
ans = (long long)ans + l - 1;
}
printf("%lld\n",ans);
return 0;
}