defined nearest largest integer in array function