fork(1) download
  1. n=int(input())
  2. a=[int(n) for n in input().split(' ')]
  3. k=list(set(a))
  4. k=sorted(k)
  5. print(k)
  6. t=0
  7. for i in k:
  8. a.remove(i)
  9. if (i-1) in a:
  10. a.remove(i-1)
  11. if (i+1) in a:
  12. a.remove(i+1)
  13. t=t+i
  14. if(len(a)==0):
  15. break
  16. print(t)
Runtime error #stdin #stdout #stderr 0.02s 27720KB
stdin
8 
7 2 1 8 3 3 6 6
stdout
[1, 2, 3, 6, 7, 8]
stderr
Traceback (most recent call last):
  File "./prog.py", line 8, in <module>
ValueError: list.remove(x): x not in list