Store the array numbers and their indices
let arr = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { arr [ i ] = new Array ( n ) . fill ( 0 ) } for ( let i = 0 ; i < n ; i ++ ) { arr [ i ] [ 0 ] = a [ i ] ; arr [ i ] [ 1 ] = i ; }