fork download
  1. n = int(input())
  2. a = list(map(int, input().split()))
  3.  
  4. d = {}
  5. for i in a:
  6. if i not in d: d[i] = 0
  7. d[i] += 1
  8.  
  9. items = list(d.items())
  10. items.sort(key=lambda x: 10**6*x[1]-x[0], reverse=True)
  11. print(*sorted([items[0][0], items[1][0], items[2][0]]))
Success #stdin #stdout 0.08s 14084KB
stdin
8
11 21 31 41 31 41 11 21
stdout
11 21 31