#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define int lli
main() {
    int n;
    cin>>n;
    int a[n];
    int odd=0,even=0;
    vector<int> o;
    vector<int> e;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            even++;
            e.push_back(a[i]);
        }else{
            odd++;
            o.push_back(a[i]);
        }
    }

    if(even == odd || even == odd+1 || odd == even+1){
        cout<<"0\n";
    }else{
        sort(o.begin(),o.end());
        sort(e.begin(),e.end());
        int sum=0;
        if(even > odd){
            int x = even - odd - 1;
            for(int i=0;i<x;i++)sum+=e[i];
            cout<<sum<<"\n";
        }else{
            int x = odd - sum - 1;
            for(int i=0;i<x;i++)sum+=o[i];
            cout<<sum<<"\n";
        }
    }
    return 0;
}
