N,M = map(int, input().split()) a = map(int, input().split()) b = [0] * N c = 0 d = 0 e = [] for i in range (M): b[a[i]] += 1 for i in range (N + 1): if b[i] >= c: c = b[i] e[d] = i d += 1 print(*e) For some reason, an error appears in the line b [a [i]], although b is an array created from zeros and in principle it seemed to me that everything should work