Min Value

You are given an array of N integers and q queries. In each query you are given an integer value x. For each x you have to choose a value from the given array. Let, this value be y. Now your task is to find the minimum value of z. Where,

This is a companion discussion topic for the original entry at https://toph.co/p/min-value