#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  while (cin >> n) {
    vector<long long> v;
    long long c = 0, d = 0;
    for (int i = 0; i < n; i++) {
      long long p;
      cin >> p;
      v.push_back(p);
      if (p % 2 == 0)
        c++;
      else
        d++;
    }
    sort(v.begin(), v.end());
    if (c == d || (c + 1 == d) || (d + 1 == c)) {
      cout << 0 << endl;
    } else {
      long long sum = 0, x = 0, y = 0;
      if (d == 0 || c == 0) {
        for (int i = 0; i < n - 1; i++) {
          sum += v[i];
        }
        cout << sum << endl;
      } else if (c > d && d != 0) {
        for (int i = n - 1; i >= 0; i--) {
          if (v[i] % 2 != 0) {
            v[i] = -1;
          }
        }
        for (int i = n - 1; i >= 0; i--) {
          if (v[i] % 2 == 0) {
            v[i] = -1;
            x++;
          }
          if (x == d + 1) break;
        }
        for (int i = 0; i < n; i++) {
          if (v[i] != -1) sum += v[i];
        }
        cout << sum << endl;
      } else if (d > c && c != 0) {
        for (int i = n - 1; i >= 0; i--) {
          if (v[i] % 2 == 0) {
            v[i] = -1;
          }
        }
        for (int i = n - 1; i >= 0; i--) {
          if (v[i] % 2 != 0 && v[i] != -1) {
            v[i] = -1;
            y++;
          }
          if (c + 1 == y) break;
        }
        for (int i = 0; i < n; i++) {
          if (v[i] != -1) sum += v[i];
        }
        cout << sum << endl;
      }
    }
  }
  return 0;
}
