import math
n = int(input())
a = input().split(" ")
k1 = 0
k2 = 0
a1 = []
a2 = []
for i in range(n):
    if int(a[i]) % 2 == 0:
        k1 += 1
        a1.append(int(a[i]))
    else:
        k2 += 1
        a2.append(int(a[i]))
ab = abs(k2-k1)
if ab > 1:
    t = [k2, k1]
    l = t.index(min(t))
    if l == 1:
        a2.sort()
        print(sum(a2[:ab - 1]))
    else:
        a1.sort()
        print(sum(a1[:ab - 1]))
else:
    print(0)
