n = int(input())
a = [int(x) for x in input().split()]
odd = []
even = []
for j in range(len(a)):
    if a[j]&1:
        odd.append(a[j])
    else:
        even.append(a[j])
diff = abs(len(odd) - len(even))
ans = 0
if diff>1:
    if len(odd)>len(even):
        odd.sort()
        for i in range(diff-1):
            ans+=odd[i]
    else:
        even.sort()
        for i in range(diff - 1):
            ans += even[i]
print(ans)