n = int(input())

nums = list(map(int, input().split()))

nums.sort()

odds = []
evens = []

for num in nums:
    if num % 2 == 0:
        odds.append(num)
    else:
        evens.append(num)

diff = len(odds) - len(evens)

sum = 0

if diff > 1:
    for i in range(diff - 1):
        sum += odds[i]
elif diff < -1:
    for i in range(abs(diff) - 1):
        sum += evens[i]

print(sum)
