n = int(input())
a = list(map(int,input().split()))
o = []
e = []
for i in range(n):
    if a[i] % 2 != 0:
        o.append(a[i])
    else:
        e.append(a[i])
o.sort()
e.sort()
c = 0
if sum(e) >= sum (o):
    c = 1
while len(e) > 0 and len(o) > 0:
    if c == 1:
        e.pop()
        o.pop()
    else:
        e.pop()
        o.pop()
        

if c == 0 and len(o) > 0:
    o.pop()
if c == 1 and len(e) > 0:
    e.pop()
print(sum(o) + sum(e))