#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const long long int N = 1e7 + 5;
const long long int Mx = 2e5 + 5;
vector<bool> visited;
std::vector<long long int> global;
bool isvowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') return true;
  return false;
}
int SumOfDigit(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
bool PowerTwo(long long int n) {
  if (n == 0) return false;
  return (ceil(log2(n)) == floor(log2(n)));
}
bool LinearSearch(long long int a[], long long int n, long long int x) {
  for (long long int i = 0; i < n; i++)
    if (a[i] == x) return true;
  return false;
}
long long fact(long long int n) {
  if (n > 1)
    return n * fact(n - 1);
  else
    return 1;
}
bool Prime(long long int n) {
  if (n <= 1) {
    return false;
  }
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
void Sieve() {
  vector<bool> p(Mx, true);
  for (long long int i = 2; i * i <= Mx; i++) {
    if (p[i] == true) {
      for (long long int j = i * i; j <= Mx; j += i) {
        p[j] = false;
      }
    }
  }
  for (long long int i = 2; i * i <= Mx; i++) {
    if (p[i]) {
      global.push_back(i);
    }
  }
}
int PrnitDivisor(long long int n) {
  long long int cnt = 0;
  for (long long int i = 1; i <= n; i++) {
    if (n % i == 0) {
      cnt++;
    }
  }
  return cnt;
}
void Soln() {
  long long int n, x, mnodd = 10000000, mneven = 10000000, cnt1 = 0, cnt = 0,
                      sum = 0;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      cnt++;
    } else {
      cnt1++;
    }
  }
  sort(a, a + n);
  for (long long int i = 0; i < n - 1; i++) {
    sum += a[i];
  }
  for (long long int i = 0; i < n; i++) {
    if (a[i] % 2 == 0 && mneven > a[i]) {
      mneven = a[i];
    } else if (a[i] % 2 != 0 && mnodd > a[i]) {
      mnodd = a[i];
    }
  }
  if (cnt1 == cnt || cnt1 == cnt - 1 || cnt == cnt1 - 1) {
    cout << "0" << endl;
  } else if (cnt1 == 0 || cnt == 0) {
    cout << sum << endl;
  } else {
    if (cnt1 > cnt) {
      cout << mnodd << endl;
    } else {
      cout << mneven << endl;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  Soln();
  return 0;
}
