Traverse the array and calculate count of elements which are not 1
for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] != 1 ) : NEW_LINE INDENT arr [ count1 ] = arr [ i ] NEW_LINE count1 += 1 NEW_LINE DEDENT DEDENT