n=int(input())
l=list(map(int,input().split()))
e=[]
o=[]
for i in l:
    if i%2==0:
        e.append(i)
    else:
        o.append(i)
e.reverse()
o.reverse()
if len(e)>=len(o):
    c=0
else:
    c=1
while n:
    if c%2==0 and len(e)>0:
        e.pop(0)
        print(e)
        c=c+1
    elif c%2!=0 and len(o)>0:
        o.pop(0)
        c=c+1
        print(o)
    else:
        break
    n=n-1
s1=0
for i in e:
    s1=s1+i
s2=0
for j in o:
    s2=s2+j
print(s1+s2)
    
