#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, max_height = 0, cur_sum = 0;
  cin >> n;
  vector<pair<int, int> > dims;
  for (int i = 0; i < n; i++) {
    int w, h;
    cin >> w >> h;
    dims.push_back(pair<int, int>(w, h));
    max_height = max(max_height, max(w, h));
    cur_sum += w;
  }
  int answer = max_height * cur_sum;
  for (int i = 1000; i >= 0; i--) {
    int n_swaps = 0, total_width = 0, invalid = 0;
    vector<int> decreases;
    for (int j = 0; j < n; j++) {
      if (dims[j].second > i && dims[j].first > i) {
        invalid = 1;
      } else if (dims[j].second > i && dims[j].first <= i) {
        n_swaps += 1;
        total_width += dims[j].second;
      } else if (dims[j].second <= i && dims[j].first <= i) {
        decreases.push_back(dims[j].second - dims[j].first);
        total_width += dims[j].first;
      } else {
        total_width += dims[j].first;
      }
    }
    sort(decreases.begin(), decreases.end());
    for (int k = 0; k < min((int)decreases.size(), (int)(n / 2 - n_swaps));
         k++) {
      if (decreases[k] < 0) total_width += decreases[k];
    }
    if (!invalid && n_swaps <= n / 2) {
      answer = min(answer, i * total_width);
    }
  }
  cout << answer << endl;
}
