FDibbins, sorry. But it is working only when the numbers are in ascending. It is not giving accurate result where the numbers are not in ascending order.