n = int(input())
ms = input().split()

chet, nechet = [], []
for i in range(n):
    ms[i] = int(ms[i])
    if ms[i] % 2 == 0:
        chet.append(ms[i])
    else:
        nechet.append(ms[i])
a = len(chet)
b = len(nechet)
c = max(a, b) - min(a, b) - 1
if c <= 0 :
    print(0)
elif a > b:
    chet.sort()
    print(sum(chet[:c]))
else:
    nechet.sort()
    print(sum(nechet[:c]))