n = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
s = 0
odd = []
even = []
for i in range(len(a)):
    s += a[i]
    if a[i] % 2 == 0:
        even.append(a[i])
    else:
        odd.append(a[i])
l = max(len(odd), len(even))
for i in range(l):
    if len(odd) == 0:
        if len(even) != 0:
            s -= even[0]
            even.pop(0)
        break
    if len(even) == 0:
        if len(odd) != 0:
            s -= odd[0]
            odd.pop(0)
        break
    s -= even[0]
    even.pop(0)
    s -= odd[0]
    odd.pop(0)
print(s)

