n = int(input())
a = list(map(int,input().split()))

n_2 = []
n_2_1 = []
for num in a:
    if num % 2 == 0:
        n_2.append(num)
    else:
        n_2_1.append(num)
n_2.sort()
n_2_1.sort()

a = len(n_2)
b = len(n_2_1)

if a >= b:
    print(sum(n_2[:-(b + 1)]))
else:
    print(sum(n_2_1[:-(a + 1)]))