Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. n = int(input())
  2. ch = []
  3. nch = []
  4.  
  5. for i in range(n):
  6. a = int(input())
  7. if a % 2 == 0:
  8. ch.append(a)
  9. else:
  10. nch.append(a)
  11.  
  12. ch.sort()
  13. nch.sort()
  14.  
  15. if len(ch) % 2 == 1:
  16. ch[0] = 0
  17. if len(nch) % 2 == 1:
  18. nch[0] = 0
  19.  
  20. if len(ch) == 1 and len(nch) == 1:
  21. print(-1)
  22. else:
  23. print(sum(ch) + sum(nch))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement