#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
bool ispossible(vector<int>& arr, int mid, int m) {
  int sum = 0, i = 0, j = 0, n = arr.size();
  while (j < n) {
    if (j != 0 && j % mid == 0) {
      i++;
    }
    sum += max(0, arr[j] - i);
    j++;
  }
  if (sum >= m) return 1;
  return 0;
}
void solve() {
  int n, m, sum = 0;
  cin >> n >> m;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  if (sum < m) {
    cout << -1 << endl;
    return;
  }
  if (sum == m) {
    cout << n << endl;
    return;
  }
  sort(arr.rbegin(), arr.rend());
  int lo = 1, hi = n, mid, ans;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    if (ispossible(arr, mid, m)) {
      ans = mid;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
