n = int(input())
a = list(map(int, input().split()))

even = []
odd = []

for i in range(n):
    if a[i] % 2 == 0:
        even.append(a[i])
    else:
        odd.append(a[i])

even.sort()
odd.sort()

len_e = len(even)
len_o = len(odd)

diff = abs(len_e - len_o)
if diff == 1 or diff == 0:
    print(0)
elif len_e > len_o:
    print(sum(even[0:diff - 1]))
else:
    print(sum(odd[0:diff - 1]))
