
N = int(input())
a = list(map(int, input().split()))
odds = []
evens = []
for n in a:
    if n % 2 == 0:
        evens.append(n)
    else:
        odds.append(n)
odds.sort()
evens.sort()
lo = len(odds)
le = len(evens)
if abs(lo-le) < 1:
    print(0)
    exit(0)
if lo > le:
    print(sum(odds[0:lo-le-1]))
else:
    print(sum(evens[0:le-lo-1]))
