adding my own algorithm for computing min and sec min in a 1D array