Maximum value of | arr [ 0 ] | Java implementation of the approach ; Function to return the maximum required value ; Driver code
class GFG { static int maxValue ( int n ) { if ( n == 1 ) return 0 ; return ( ( n * n / 2 ) - 1 ) ; } public static void main ( String args [ ] ) { int n = 4 ; System . out . print ( maxValue ( n ) ) ; } }