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. t=0
  6. for i in k:
  7. a.remove(i)
  8. a.remove(i-1)
  9. a.remove(i+1)
  10. t=t+i
  11. if(len(a)==0):
  12. break
  13. print(t)
Runtime error #stdin #stdout #stderr 0.02s 27704KB
stdin
8 
7 2 1 8 3 3 6 6
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 8, in <module>
ValueError: list.remove(x): x not in list