def partition(T, p, r):
    pivot = T[r]
    i = p-1
    for j in range(p, r):
        if T[j] <= pivot:
            i += 1
            T[i], T[j] = T[j], T[i]
    T[i+1], T[r] = T[r], T[i+1]
    return i+1


def quicksort(T, p, r):
    while p < r:
        q = partition(T, p, r)
        if q-p <= r-q:
            quicksort(T, p, q-1)
            p = q+1
        else:
            quicksort(T, q, r)
            r = q-1


n = int(input())
T = list(map(int, input().split()))
quicksort(T, 0, len(T)-1)
even = odd = 0
result = 0
for i in range(len(T)):
    if T[i] % 2 == 0:
        even += 1
    else:
        odd += 1
if abs(even-odd) <= 1:
    print(0)
elif even > odd:
    x = even-odd
    for i in range(x):
        result += T[i]
    print(result)
else:
    x = odd-even
    for i in range(x):
        result += T[i]
    print(result)