Driver code
public static void main ( String args [ ] ) { int [ ] arr = { 3 , 2 , 1 , 2 , 1 , 4 , 5 , 8 , 6 , 7 , 4 , 2 } ; int n = arr . length ; System . out . println ( maxDistance ( arr , n ) ) ; } }