n = int(input())
a = [int(s) for s in input().split()]
a.sort()
ch = []
nh = []
c, h = 0, 0
for i in range(n):
    if a[i] % 2 == 0:
        ch.append(a[i])
    else:
        nh.append(a[i])
r = abs(len(ch) - len(nh)) - 1
s = 0
if r > 0:
    if len(ch) > len(nh):
        s = sum(ch[:r])
    else:
        s = sum(nh[:r])
print(s)
