#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int>
#define all(v) v.begin(), v.end()
#define mt make_tuple
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
#define hash hash1
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R)
{
     int val = rng() % R;
     assert(val >= 0);
     return val;
}

const long double PI = atan(1.0) * 4;
const int32_t INF32 = 2e9 + 7;
const int64_t INF64 = 3e18;
const int32_t LOG = 21;
int32_t MOD = MOD1;

using namespace std;

//-------------------DEBUGGING-------------------------
void my_debugger(string s, int LINE_NUM) { cerr << endl; }
template <typename start, typename... end>
void my_debugger(string s, int LINE_NUM, start x, end... y)
{
     if (s.back() != ',')
     {
          s += ',';
          cerr << "LINE(" << LINE_NUM << "): ";
     }
     int i = s.find(',');
     cerr << s.substr(0, i) << " = " << x;
     s = s.substr(i + 1);
     if (!s.empty())
          cerr << ", ";
     my_debugger(s, LINE_NUM, y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__, __LINE__, __VA_ARGS__);
#else
#define debug(...) ;
#endif

//-----------------------------------------------------

struct segtree
{
     vector<int> t;
     vector<int> lazy;
     vector<int> a;
     int n;
     
     void build(int i,int l,int r)
     {
            int mid=(l+r)>>1;
            if(l==r)
            {
                 t[i]=a[l];
                 return;
            }
            build(2*i,l,mid);
            build(2*i+1,mid+1,r);
            t[i]=t[2*i]+t[2*i+1];
     }

     segtree(int n): t(4*n+4), lazy(4*n+4)
     {
          this->n = n;
     }

     segtree(int n,vector<int>& v): t(4*n+4),lazy(4*n+4), a(v)
     {
         this->n=n;
         build(1,1,n);
     }
 
     void push(int i,int tl,int tr)
     {
           t[i]+=(tr-tl+1)*lazy[i];
           if(tl==tr)
           {
                lazy[i]=0;
                return;
           }
           lazy[2*i+1]+=lazy[i];
           lazy[2*i]+=lazy[i];
           lazy[i]=0;
     }
 
     void update1(int i,int tl,int tr,int l,int r,int inc)
     {
          push(i,tl,tr);
          if(l>r)return;
          if(l<=tl && tr<=r)
          {
               lazy[i]+=inc;
               push(i,tl,tr);
               return;
          }
          
          int tmid=(tl+tr)>>1;
          update1(2*i,tl,tmid,l,min(tmid,r),inc);
          update1(2*i+1,tmid+1,tr,max(l,tmid+1),r,inc);
          t[i]=t[2*i]+t[2*i+1]; 
     }
 
     void update(int l,int r,int inc)
     {
          update1(1,1,n,l,r,inc);
     }
 
     int query1(int i,int tl,int tr,int l,int r)
     {
          push(i,tl,tr);
          if(l>r)return 0;
          if(l<=tl && tr<=r)
          return t[i];
          int tmid=(tl+tr)>>1;
          return query1(2*i,tl,tmid,l,min(tmid,r))+query1(2*i+1,tmid+1,tr,max(l,tmid+1),r);
     }  
 
     int query(int l,int r)
     {
          return query1(1,1,n,l,r);
     }

     int bound1(int i,int tl,int tr,int lim)
     {
          push(i,tl,tr);
          if(t[i]<lim)return -1;
          if(tl==tr)return tr;
          int tmid=(tl+tr)>>1;
          push(2*i,tl,tmid);
          if(t[2*i]>=lim)return bound1(2*i,tl,tmid,lim);
          return bound1(2*i+1,tmid+1,tr,lim-t[2*i]);  
     }

     int bound(int lim)
     {
          return bound1(1,1,n,lim); 
     }
};

int32_t main()
{
     getFaster;
     //files_init();
     int tests = 1;
     //cin >> tests;
     rep(ii, 0, tests)
     {
           int n,k;
           cin>>n>>k;
           vector<int> a(n);
           rep(i,0,n)cin>>a[i];
           sort(a.rbegin(),a.rend());
           int BIG=200001;
           segtree seg(3*BIG+5);
           int ptr=0;
           int ans=-1;
           rep(i,0,3*n+1)
           {
                debug(i);
                if(ptr==a.size())break;
                int vals=(i==0?1:seg.query(i,i));
                if(vals>0)
                {
                      if(i!=0)
                      seg.update(i,i,-1); 
                      int l1,r1,l2,r2;
                      if(a[ptr]&1)
                      {
                           l1=i+2;
                           r1=l1+(a[ptr]/2)-1;
                           l2=l1;
                           r2=r1;
                      }
                      else
                      {
                           l1=i+2;
                           r1=l1+(a[ptr]/2)-1;
                           l2=l1;
                           r2=r1-1;
                      }
                      seg.update(l1,r1,1);
                      seg.update(l2,r2,1);
                      int bound=seg.bound(k);
                      if(bound!=-1)
                      {
                           if(ans==-1 || ans>bound)
                           ans=bound;
                      }
                      if(vals>1)
                      i--;
                      ptr++;
                }
           }
           cout<<ans<<endl;  
     }
     return 0;
}