#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int num[MAXN];
int max(int a, int b) { return a > b ? a : b; }
int cmp(int x, int y) { return x > y; }
int check(int N, int t, int res) {
  for (int i = 0; i < N; i++) {
    res -= max(0, num[i] - i / t);
    if (res <= 0) return 1;
  }
  return 0;
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%d", &num[i]);
  }
  sort(num, num + N, cmp);
  int l = 1, r = N;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check(N, mid, M)) {
      r = mid;
    } else
      l = mid + 1;
  }
  if (check(N, N, M))
    printf("%d\n", r);
  else
    printf("-1\n");
  return 0;
}
