Store the value in struct Array
for ( int i = 1 ; i <= n ; ++ i ) { v [ i - 1 ] = v [ i - 1 ] - 1 ; int x = v [ i - 1 ] ; where [ x ] = i - 1 ; arr [ i - 1 ] . val = x ; arr [ i - 1 ] . index = i - 1 ; }