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