There should be atleast two elements
if ( n < 2 ) { System . out . println ( " Invalid ▁ Input " ) ; return ; } int firstSmallest = Integer . MAX_VALUE ; int secondSmallest = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) {