Find an index i such the a [ i ] is odd and compare length of both halfs excluding a [ i ] to find max length subarray
for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ a [ $ i ] % 2 == 1 ) $ len = max ( $ len , $ max ( $ n - $ i - 1 , $ i ) ) ; } return $ len ; }