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. if (i-1) in a:
  9. a.remove(i-1)
  10. if (i+1) in a:
  11. a.remove(i+1)
  12. t=t+i
  13. if(len(a)==0):
  14. break
  15. print(t)
Runtime error #stdin #stdout #stderr 0.02s 28384KB
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 7, in <module>
ValueError: list.remove(x): x not in list