Now all non - ones elements have been shifted to front and ' count1' is set as index of first 1. Make all elements 1 from count to end .
while ( count1 < n ) : NEW_LINE INDENT arr [ count1 ] = 1 NEW_LINE count1 += 1 NEW_LINE DEDENT