
n = int(input())
arr = list(map(int,input().split()))
even = []
odd = []
for i in range(n):
    if(arr[i]%2 ==0):
        even.append(arr[i])
    else:
        odd.append(arr[i])

l = len(odd)
r = len(even)
mina = min(l,r)
even.sort(reverse = True)
odd.sort(reverse = True)
ans = sum(arr)
suma = 0
for i in range(mina):
    suma += odd[i] + even[i]

if(l == mina and l!= r):
    suma += even[mina]
elif(r == mina and r!= l):
    suma += odd[mina]

print(ans - suma)
