n = int(input())
a = [int(num) for num in input().split()]
e, o, ans = list(filter(lambda n : n%2 == 0, a)), list(filter(lambda n : n%2 != 0, a)), 0
e.sort(reverse=True), o.sort(reverse=True)
temp = abs(len(e)-len(o))
if temp > 1 :
    ans = sum(e[len(o)+1:]) if len(e) > len(o) else sum(o[len(e)+1:])
print(ans)
