#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int inf = 1000 * 1000 * 1000;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  long long n, t, zuyg = 0, kent = 0, ans = 0, qan = 0;
  cin >> n;
  vector<long long> a;
  for (int i = 0; i < n; i++) {
    cin >> t;
    a.push_back(t);
    if (t % 2 == 0) {
      zuyg++;
      continue;
    }
    kent++;
  }
  sort(a.begin(), a.end());
  if (abs(kent - zuyg) == 1 || zuyg == kent) {
    cout << 0 << endl;
    return 0;
  }
  if (kent < zuyg) {
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0) {
        ans += a[i];
        qan++;
      }
      if (qan == zuyg - kent - 1) {
        break;
      }
    }
    cout << ans << endl;
  }
  if (zuyg < kent) {
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 1) {
        ans += a[i];
        qan++;
      }
      if (qan == kent - zuyg - 1) {
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
