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
var n = 3 ; var input = [ 2 , 5 , 6 , 7 , 11 ] ;