n = int(input())
a = [int(t) for t in input().split(' ')]
a.sort()

minsum = sum(a)
for pi in range(0, 2):
    p0 = [t for t in a if t % 2 == 0]
    p1 = [t for t in a if t % 2 == 1]
    pn = [p0, p1]

    p = pi
    while len(pn[p]):
        pn[p].pop()
        p = 1 - p
    minsum = min(minsum, sum(p0 + p1))

print(minsum)
