//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#define pb push_back
#define mpr make_pair
#define int long long
#define lb lower_bound
#define up upper_bound
#define sqr(x) ((x) * 1ll *(x))

using namespace std;

typedef pair <int, int> pii;
typedef unsigned long long ull;

const int MAXM = 1e5 + 5;
const int MAXN = 1e6 + 5;
const int INF = 1e7 + 9;
const int MOD = 1e9 + 9;
const int MX = 1e9;

const int X[] = {1,-1,0,0}, Y[] = {0,0,1,-1};

int a[2001], d[2001], D[2001];
int cnt, cnt1;
vector <int> odd, even;
main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        if(a[i] % 2 == 0)
        {
            ++cnt;
            even.pb(a[i]);
        }
        else
        {
            ++cnt1;
            odd.pb(a[i]);
        }
    }
    sort(even.begin(), even.end());
    sort(odd.begin(), odd.end());
    if(abs(cnt - cnt1) > 1)
    {
        if(cnt > cnt1)
        {
            for(int i = 0; i < even.size(); ++i)
                d[i+1] = d[i] + even[i];
            if (cnt1)
                cout << d[even.size() - (2 * odd.size())];
            else
                cout << d[cnt-1];
        }
        else
        {
            for(int i = 0; i < odd.size(); ++i)
                D[i+1] = D[i] + odd[i];
            if(cnt)
                cout << D[odd.size() - (2 * even.size())];
            else
                cout << D[cnt1-1];
        
        }
    }
    else
    {
        cout << 0;
    }
}
    