Condition to check if the length of the array is odd
if ( ( n & 1 ) ) { left = a [ n / 2 ] ; right = b [ n / 2 ] ; ans = right - left + 1 ; } else { left = ( a [ n / 2 ] + a [ n / 2 - 1 ] ) ; right = ( b [ n / 2 ] + b [ n / 2 - 1 ] ) ; ans = right - left + 1 ; } cout << ans << endl ; }