import sys

n = int(sys.stdin.readline().strip())

arr = map(int, sys.stdin.readline().strip().split())

arr = sorted(arr)

odd_arr, even_arr = [], []

for item in arr:
    if item % 2 == 0:
        even_arr.append(item)
    else:
        odd_arr.append(item)

if len(even_arr) > len(odd_arr):
    del even_arr[-1]
    last_type = 0
else:
    del odd_arr[-1]
    last_type = 1

while len(odd_arr) != 0 and len(even_arr) != 0:
    if last_type == 0:
        del odd_arr[-1]
        last_type = 1
    else:
        del even_arr[-1]
        last_type = 0

if last_type == 0 and len(odd_arr) >= 1:
    del odd_arr[-1]
if last_type == 1 and len(even_arr) >= 1:
    del even_arr[-1]

print sum(even_arr) + sum(odd_arr)
