Maximum value of | arr [ 0 ] | C ++ implementation of the approach ; Function to return the maximum required value ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int maxValue ( int n ) { if ( n == 1 ) return 0 ; return ( ( n * n / 2 ) - 1 ) ; } int main ( ) { int n = 4 ; cout << maxValue ( n ) ; return 0 ; }