n = int(input())
a = list(map(int,input().split()))
a.sort()

n2 = 0
n21 = 0
for num in a:
    if num % 2 == 0:
        n2 += 1
    else:
        n21 += 1

if n2 == n21 or n21 > n2:
    for i in range(1,n+1):
        if i % 2 == 0:
            ost = 0
        else:
            ost = 1
        for j in range(len(a)):
            if a[j] % 2 == ost:
                del a[j]
                break
        else:
            break
elif n2 > n21:
    for i in range(2,n+2):
        if i % 2 == 0:
            ost = 0
        else:
            ost = 1
        for j in range(len(a)):
            if a[j] % 2 == ost:
                del a[j]
                break
        else:
            break

if a == []:
    print(0)
else:
    print(sum(a))
