from math import sqrt, ceil, floor
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
import string


n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
k = [x for x in a if x % 2 == 0]
z = [x for x in a if x % 2 == 1]
k.sort()
z.sort()
if len(z) == len(k):
    print(0)
elif len(z) > len(k):
    print(sum(z[:len(z)-len(k)-1]))
else:
    print(sum(k[:len(k)-len(z)-1]))
