n = int(input())
lis = list(map(int, input().split()))
e = []
o = []
for i in lis:
    if i%2==0:
        e.append(i)
    else:
        o.append(i)
diff = len(e)-len(o)
summ = 0
if diff == 0 or diff == -1 or diff == 1:
    print(0)
else:
    if diff > 0:
        e.sort()
        for i in range(0, diff-1):
            summ = summ + e[i]
    else:
        diff = -1* diff
        o.sort()
        for i in range(0, diff-1):
            summ = summ + o[i]
    print(summ)
