n, m = gets.split.map &:to_i x = gets.to_i a = Array.new(n - 1) { gets.to_i }.sort.reverse pos = a.bsearch_index do |i| b = a.dup b.delete_at(a.index i) m <= b.each_slice(2).count { |j| x + i < j.sum } end || n - 1 puts pos > 0 ? a[pos - 1] : -1