n = int(input())
arr = map(int, input().split(" "))
arr = sorted(arr)
odd, even = [], []
for i in range(n):
    if arr[i] % 2 == 0:
        even.append(arr[i])
    else:
        odd.append(arr[i])
diff = len(odd) - len(even)
sum = 0
if diff > 1:
    for j in range(diff -  1):
        sum += odd[j]
elif diff < -1:
    for j in range(abs(diff) - 1):
        sum += even[j]
print(sum)