n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
s = sum(A)
B, C = [], []
for i in A:
    if i % 2 == 0:
        B.append(i)
    else:
        C.append(i)
b, c = 0, 0
for i in range(min(len(B), len(C))):
    b += B[i] + C[i]
    c += B[i] + C[i]

if(len(B) > len(C)):
    b += B[min(len(B), len(C))]
elif(len(B) < len(C)):
    c += C[min(len(B), len(C))]

print(min(s-b, s-c))

