n = int(input())
a = sorted(list(map(int, input().split())))
chet = list(i for i in a if i % 2 == 0)
nechet = list(i for i in a if i % 2 != 0)
if len(chet) == len(nechet) or abs(len(chet) - len(nechet)) == 1:
    print(0)
elif len(chet) > len(nechet):
    x = len(chet) - len(nechet) - 1
    print(sum(chet[:x]))
else:
    x = len(nechet) - len(chet) - 1
    print(sum(nechet[:x]))
