i = input()
data = input()
this_is = list(map(int, data.split()))
all = len(this_is)
chet, nechet = [[],[]]
for i in this_is:
    if i%2:
        nechet.append(i)
    else:
        chet.append(i)
n_chet = len(chet)
n_nechet = len(nechet)

if n_chet - n_nechet in [-1,1,0]:
    print(0)
else:
    if n_nechet > n_chet:
        print(sum(sorted(nechet)[:-1]))
    else:
        print(sum(sorted(chet)[:-1]))
