title: Find a number nearest to all numbers in an array
body: <p>This problem is basically an algorithm optimization problem.</p>
  
  <p>We have a list which has n elements. for e.g. <code>{n1,n2,n3...nk}</code>
  This list is sorted and we have to find out the number ni which is</p>
  
  <ol>
  <li><code>n1&lt;=ni&lt;=nk</code></li>
  <li>The sum of distance of <code>ni</code> from each number is minimum.</li>
  </ol>
  
  <p>There may be total <code>(nk-n1+1)</code> possible numbers but our objective is to find out the number <code>ni</code> which is
  nearest to all other numbers.</p>
  
  <p>Brute force approach could be iterate through <code>n1</code> to nk and calculate the sum of distance
  from all list numbers. This way easily we can figure out the number who is closest to all other numbers in the list. </p>
  
  <p>But the problem with this approach is, it is not good in terms of time complexity. The time complexity of this approach is <code>O(n^2)</code>. </p>
  
  <p>I think there could be better method to do this which can solve this problem with less time 
  complexity. </p>
  
  <p>Any approach will be appreciated.</p>