n = int(input())

mas = input().split(' ')
for i in range(n):
    mas[i] = int(mas[i])
mas.sort()

chet = []
nechet = []
for i in range(n):
    if mas[i] % 2 == 0:
        chet.append(mas[i])
    else:
        nechet.append(mas[i])
if len(chet) > len(nechet):
    print(sum(chet[:len(chet) - len(nechet) -1]))
elif len(chet) < len(nechet):
    print(sum(nechet[:len(nechet) - len(chet) - 1]))
else:
    print(0)