n = int(input())
a = list(map(int,input().split()))
b = 0
c = 0
b1 = []
c1 = []
for i in range(n):
    if a[i] % 2 == 0:
        b += 1
        b1.append(a[i])
    else:
        c += 1
        c1.append(a[i])
if abs(b-c) < 2:
    print(0)
else:
    b1.sort()
    c1.sort()
    ans = 0
    if b > c:
        for i in range(b-c-1):
            ans += b1[i]
    else:
        for i in range(c-b-1):
            ans += c1[i]
    print(ans)