import sys

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split(' ')))

even = sorted(list(filter(lambda x: x%2 == 0, a)), key=lambda x: -x)
odd = sorted(list(filter(lambda x: x%2 != 0, a)), key=lambda x: -x)

s = sum(a)

if len(even) == 0:
    print(s - odd[0])
    exit()

if len(odd) == 0:
    print(s - even[0])
    exit()

x = min(len(even), len(odd))
s1 = sum(even[0:x]) + sum(odd[0:x+1])
s2 = sum(even[0:x+1]) + sum(odd[0:x])
print(s - max(s1, s2))

