n = int(input())
a = list(map(int, input().split()))
o_1 = []
o_2 = []
for i in range(n):
    if a[i] % 2 == 0:
        o_2.append(a[i])
    else:
        o_1.append(a[i])
s = 0
o_1.sort()
o_2.sort()
if len(o_1) > len(o_2):
    for i in range(len(o_1) - len(o_2) - 1):
        s += o_1[i]
    print(s)
else:
    for i in range(len(o_2) - len(o_1) - 1):
        s += o_2[i]
    print(s)