a = int(input())
x = list(map(int, input().split()))

#print(x)
x = sorted(x)
gen = [x[i] for i in range(len(x)) if x[i] % 2 == 0]
gan = [x[i] for i in range(len(x)) if x[i] % 2 != 0]

ma = max(len(gen), len(gan))
mi = min(len(gen), len(gan))

if ma - mi == 1 or ma == mi:
    print(0)
    exit(0)
sums  = 0
if len(gen) == ma:
    for i in range(ma- mi - 1):
        sums += gen[i]
    print(sums)

if len(gan) == ma:
    for i in range(ma - mi - 1):
        sums += gan[i]
    print(sums)