Generate Sequence and insert into a priority queue .
int [ ] S = new int [ N + 1 ] ; PriorityQueue < Integer > PQ = new PriorityQueue < > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { S [ i ] = i ; PQ . add ( S [ i ] ) ; }