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. print(i)
  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)
  17.  
  18.  
  19.  
Runtime error #stdin #stdout #stderr 0.01s 28384KB
stdin
8 
7 2 1 8 3 3 6 6
stdout
1
2
stderr
Traceback (most recent call last):
  File "./prog.py", line 8, in <module>
ValueError: list.remove(x): x not in list