Here's the code:
n = int(input())
arr = input().split()
arr = [int(x) for x in arr]
smallest = 1001
while(True):
    if smallest==0:
        break
    arr.sort()
    count = 0
    smallest = arr[0]
    for i in arr:
        if i==0:
            arr.remove(i)
        i-=smallest           #This statement.
        count+=1
    print(count)
For input: (n=)6 and (arr=)5 4 4 2 2 8 The output I'm getting is: 6 6 6... However, according to me, if my logic works (and the aforementioned statement actually edits my original array elements), the output should turn out to be 6 4 2 1 instead.
I might have got whole of the thing wrong. I'm an amateur. Any sort of help is appreciated.
 
     
    