Taking in the input and initializing the set STL set in cpp has a property that it maintains the elements in sorted order , thus we do not need to sort them externally
n = 3 NEW_LINE input = [ 2 , 5 , 6 , 7 , 11 ] NEW_LINE GCD = set ( ) NEW_LINE for i in range ( len ( input ) ) : NEW_LINE INDENT GCD . add ( input [ i ] ) NEW_LINE DEDENT arr = [ ] NEW_LINE for i in GCD : NEW_LINE INDENT arr . append ( i ) NEW_LINE DEDENT