n = int(input())
a = list(map(int, input().split()))
a1 = sorted(a)
ch = []
nch = []
for i in range(n):
    if a1[i] % 2 == 0:
        ch.append(a1[i])
    else:
        nch.append(a1[i])
if len(ch) == len(nch) or abs(len(ch) - len(nch)) == 1:
    print(0)
else:
    if len(ch) > len(nch):
        r = len(ch) - len(nch) - 1
        print(sum(ch[:r]))
    else:
        r = len(nch) - len(ch) - 1
        print(sum(nch[:r]))        