n = int(input())
s = list(map(int, input().split()))
z = s[0]
g = s[0]
for i in range(1, n):
    if s[i] % 2 != z % 2:
        g = s[i]
        break
otv1 = [g]
otv2 = [z]
for j in range(n):
    for i in range(1, n):
        if s[i] % 2 != g % 2 and s[i] not in otv1:
            g = s[i]
            otv1.append(s[i])
            break
    for i in range(1, n):
        if s[i] % 2 != z % 2 and s[i] not in otv2:
            z = s[i]
            otv2.append(s[i])
            break
s.sort()
if len(otv1) > len(otv2):
    lop = n - len(otv1)
    pir = []
    otv = []
    for i in range(lop):
        if s[i] % 2 == otv1[-1] and i not in pir:
            otv.append(s[i])
            pir.append(i)
            break
elif len(otv1) < len(otv2):
    lop = n - len(otv2)
    pir = []
    otv = []
    for i in range(lop):
        if s[i] % 2 == otv2[-1] and i not in pir:
            otv.append(s[i])
            pir.append(i)
            break
else:
    lop = n - len(otv2)
    otv = [0]
    for i in range(lop):
        otv = [s[0]]
        break
print(sum(otv))