#include <bits/stdc++.h>
using namespace std;
int W[100], dp1[50], dp2[50];
int main() {
  int n, min = 1000000;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) cin >> W[i];
  sort(W, W + 2 * n);
  dp1[0] = 0;
  for (int i = 0; i < n; i++) {
    if (i) dp1[i] = dp1[i - 1] + W[2 * i - 1] - W[2 * i - 2];
    dp2[i] = dp1[i];
    for (int j = i + 1; j < n; j++) dp2[i] += W[2 * j + 1] - W[2 * j];
    if (dp2[i] < min) min = dp2[i];
    for (int j = i + 1; j < n; j++) {
      dp2[j] = dp2[j - 1] + 2 * W[2 * j] - W[2 * j - 1] - W[2 * j + 1];
      if (dp2[j] < min) min = dp2[j];
    }
  }
  cout << min;
}
