t = int(input())
cnt = 0
su =0
def init(a):
    for p in range(len(a)):
        a[p] = int(a[p])
    return(a)
'''def swap(a):
    for i in range(len(a)-1):
        temp = a[i] 
        a[i] = a[i+1]
        a[i+1] = temp
    return(a)'''
d = input().split()
d =  init(d)
e =[]
o = []
for i in range(len(d)):
    if d[i]%2 == 0:
        e.append(d[i])
    else:
        o.append(d[i])
e = sorted(e)
o = sorted(o)
if len(e) == 0 or len(o) == 0:
    su = sum(d)-max(d)
elif len(e)-len(o)>1:
    for j in range(abs(len(e)-len(o))):
        su = su+e[j]
elif len(o) -len(e)>1:
    for j in range(abs(len(o)-len(e))):
        su = su+o[j]
elif abs(len(e)-len(o))<1:
    su = 0
print(su)

    

