n = int(input())
a = list(map(int, input().split()))
a1 = sorted(a)
z = True
l = [0, 1]
a1 = a1[::-1]
d = a1[0] % 2
df = a1[0] % 2
s = sum(a1) - a1[0]
for i in range(1, n):
    if d != a1[i] % 2:
        d = a1[i] % 2
        s -= a1[i]
    else:
        continue
for i in range(n):
    if l.index(a1[i] % 2) != df:
        d1 = a1[i] % 2
        num = i
        ned = a1[i]
        a1.pop(i)
        a1 = a1[::-1]
        a1.append(ned)
        a1 = a1[::-1]
        z = False
        break
if z:
    print(s)
else:
    s1 = sum(a1) - a1[0]
    for i in range(1, n):
        if d1 != a1[i] % 2:
            d1 = a1[i] % 2
            s1 -= a1[i]
        else:
            continue
    print(min(s, s1))