#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<int> p(n+1, 0);
  for(auto i : a){
    p[i]++;
  }
  vector<int> mns(n+1, 1001001001);
  mns.front() = p.front();
  rep2(i, 1, n+1){
    mns.at(i) = min(p.at(i), mns.at(i-1));
  }
  ll ans = 0, now = 0;
  rrep(i, n+1){
    if(mns.at(i) > now){
      ll d = mns.at(i) - now;
      ll adc = min((ll)k, d);
      ans += (ll)adc*(i+1);
      k -= d;
      if(k <= 0) break;
      now = mns.at(i);
    }
  }
  cout << ans << endl;
  return 0;
}
#include<bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
#define ll long long
using namespace std;
ll mod = 1e9+7;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,x;
    cin >> n >> x;
    x*=100;
    ll i=1;
    ll ans=0;
    bool drunk=false;
    while(n--){
        ll a,b;
        cin >> a >> b;
        ans+=a*b;
        if(ans>x){
            drunk=true;
            break;
        }
        i++;
    }
    if(drunk==true){
        cout << i;
    }
    else{
        cout << -1;
    }
    return 0;
}
    