
def input_s():
    return raw_input()

def input_i():
    return int(raw_input())

def input_2_i():
    arr = map(int, raw_input().split())
    return arr[0], arr[1]

def input_3_i():
    arr = map(int, raw_input().split())
    return arr[0], arr[1], arr[2]

def input_i_array():
    return map(int, raw_input().split())

def get_presum(n, arr):
    presum = [arr[0]]
    for i in range(1, n):
        presum.append(presum[i - 1] + arr[i])
    return presum

def calc(n, arr):
    odd_nums = [x for x in arr if x % 2 == 1]
    even_nums = [x for x in arr if x % 2 == 0]
    lo = len(odd_nums)
    le = len(even_nums)
    if abs(lo - le) == 1 or abs(lo - le) == 0:
        return 0

    if lo == 0:
        return sum(sorted(even_nums)[:-1])
    if le == 0:
        return sum(sorted(odd_nums[:-1]))
    
    if lo < le:
        return sum(sorted(even_nums)[: le - lo - 1])
    return sum(sorted(odd_nums)[: lo - le - 1])

"""
5
1 5 7 8 2
"""

n = input_i()
arr = input_i_array()
print calc(n, arr)
