n = int(input())
A = sorted(list(map(int, input().rstrip().split())), reverse=True)

even = []
odd = []
s = 0

for a in A:
    if a % 2 == 0:
        even.append(a)
    else:
        odd.append(a)

if len(even) > len(odd):
    even = sorted(even, reverse=True)

    for i in range(len(odd) + 1, len(even)):
        s += even[i]

elif len(even) < len(odd):
    odd = sorted(odd, reverse=True)

    for i in range(len(even) + 1, len(odd)):
        s += odd[i]

print(s)
