Python script for getting min and max of a list in 3n/n -2 time complexity