n = int(input())
a = list(map(int, input().split()))
chet, nechet = 0, 0
chet_a = []
nechet_a = []
for i in a:
    if i % 2 == 0:
        chet += 1
        chet_a.append(i)
    else:
        nechet += 1
        nechet_a.append(i)
m = None
if len(nechet_a) > len(chet_a):
    m = nechet_a
else:
    m = chet_a

if abs(chet - nechet) > 1:
    s = 0
    m.sort()
    for i in range(abs(chet - nechet) - 1):
        s+=m[i]
    print(s)
else:
    print(0)
