require'prime' k=gets.to_i f=m=z=0 q=[] Prime.each(gets.to_i){|x| x0 q<l||(m=l;z=q[0]) ) } p z