#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int n,x,ans;
vector<int> v1,v2;
inline int read(){
    int x=0;
    bool sign=false;
    char alpha=0;
    while(!isdigit(alpha)) sign|=alpha=='-',alpha=getchar();
    while(isdigit(alpha)) x=(x<<1)+(x<<3)+(alpha^48),alpha=getchar();
    return sign?-x:x;
}
int main(){
    n=read();
    for(int i=1;i<=n;i++){
        x=read();
        x&1?v1.push_back(x):v2.push_back(x);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    int dif=abs(v1.size()-v2.size());
    if(dif==1) return 0&printf("0\n");
    if(v1.size()==0) for(int i=0;i<v2.size()-1;i++) ans+=v2[i];
    else if(v2.size()==0) for(int i=0;i<v1.size()-1;i++) ans+=v1[i];
    else if(v1.size()>v2.size()) for(int i=0;i<dif;i++) ans+=v1[i];
    else if(v1.size()<v2.size()) for(int i=0;i<dif;i++) ans+=v2[i];
    printf("%d\n",ans);
    return 0;
}