finding maximum and minimum element in array is completed