#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int> > arr;
long long solve1(vector<pair<int, int> > tab) {
  multiset<int> S;
  int W = 0;
  for (int i = 0; i < n; i++) {
    W += tab[i].first;
    S.insert(tab[i].second);
  }
  for (int j = 0; j < n / 2; j++) {
    int id = -1;
    long long best = 0;
    for (int i = 0; i < n; i++) {
      multiset<int>::iterator it = S.end();
      it--;
      long long cur = W * 1LL * (*it);
      S.erase(S.find(tab[i].second));
      it = S.end();
      it--;
      long long tmp =
          max((*it), tab[i].first) * 1LL * (W - tab[i].first + tab[i].second);
      if (cur - tmp > best) {
        best = cur - tmp;
        id = i;
      }
      S.insert(tab[i].second);
    }
    if (id == -1) break;
    S.erase(S.find(tab[id].second));
    S.insert(tab[id].first);
    W = W - tab[id].first + tab[id].second;
    swap(tab[id].first, tab[id].second);
  }
  multiset<int>::iterator it = S.end();
  it--;
  long long result = W * 1LL * (*it);
  return result;
}
long long solve2(vector<pair<int, int> > tab) {
  sort(tab.begin(), tab.end(), [](pair<int, int> A, pair<int, int> B) {
    return A.first - A.second > B.first - B.second;
  });
  for (int i = 0; i < n / 2; i++) swap(tab[i].first, tab[i].second);
  int W = 0;
  int H = 0;
  for (int i = 0; i < n; i++) {
    W += tab[i].first;
    H = max(H, tab[i].second);
  }
  long long res1 = W * 1LL * H;
  for (int i = 0; i < n / 2; i++) swap(tab[i].first, tab[i].second);
  sort(tab.begin(), tab.end(), [](pair<int, int> A, pair<int, int> B) {
    if (A.second == B.second) {
      return A.first < B.first;
    } else {
      return A.second > B.second;
    }
  });
  for (int i = 0; i < n / 2; i++) swap(tab[i].first, tab[i].second);
  W = 0;
  H = 0;
  for (int i = 0; i < n; i++) {
    W += tab[i].first;
    H = max(H, tab[i].second);
  }
  long long res2 = W * 1LL * H;
  return min(res1, res2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  arr.resize(n);
  for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second;
  long long res1 = solve1(arr);
  long long res2 = solve2(arr);
  cout << min(res1, res2) << endl;
}
