n = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
odd = []
even = []

def Parity(n, arr):
    for i in arr:
        if i%2 != 0:
            odd.append(i)
        else:
            even.append(i)

    maxlen = max(len(odd), len(even))
    minlen = min(len(odd), len(even))
    if maxlen - minlen <= 1:
        return 0
    elif len(odd) == minlen:
        return sum(even[minlen+1:])
    else:
        return sum(odd[minlen+1:])

print(Parity(n, arr))