#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> all(n);
  int odd, even;
  odd = 0;
  even = 0;
  for (int i = 0; i < n; i++) {
    cin >> all[i];
    if (all[i] % 2 == 0)
      even++;
    else
      odd++;
  }
  if (abs(odd - even) == 1)
    cout << 0;
  else {
    int k = odd - even;
    unsigned long long out = 0;
    if (k > 0) {
      sort(all.begin(), all.end());
      for (int i = 0; i < n; i++) {
        if (all[i] % 2 == 1) {
          out += all[i];
          k--;
          if (k == 1) break;
        }
      }
    } else if (k < 0) {
      k *= -1;
      sort(all.begin(), all.end());
      for (int i = 0; i < n; i++) {
        if (all[i] % 2 == 0) {
          out += all[i];
          k--;
          if (k == 1) break;
        }
      }
    }
    cout << out;
  }
}
