#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a < b) return b;     return a;   }   long long min(long long a, long long b) {     if (a < b) return a;     return b;   }   bool okay(vector<long long> &v, long long d, long long k) {     long long sum = 0;     priority_queue<long long, vector<long long>, greater<long long>> pq;     for (int i = 0; i < d; i++) pq.push(0);     for (auto x : v) {       long long ind = pq.top();       pq.pop();       sum += max(0, x - ind);       pq.push(ind + 1);     }     return sum >= k;   }   void solve() {     long long n, m;     cin >> n >> m;     vector<long long> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     sort(v.rbegin(), v.rend());     long long low = 1, high = n, ans = -1;     while (low <= high) {       long long mid = low + (high - low) / 2;       if (okay(v, mid, m)) {         ans = mid;         high = mid - 1;       } else         low = mid + 1;     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }   