Solved the problem about getting the minimum avg with O(n)