#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#ifdef LOCAL_ENV
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}

template<typename T>
vector<T> sorted(vector<T>& a) {
  auto res = a;
  sort(all(res));
  return res;
}

template<typename T>
void vec_print(vector<T>& a) {
  for (auto& v : a) cerr << v << " ";
  cerr << endl;
}
 
template<class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}

int pow_n(int a, int b) {
  int res = 1;
  rep(i, b) res *= a;
  return res;
}
 
class Solver {
public:
  int H, W;

  bool grid_ng(int y, int x) {
    return y < 0 || y >= H || x < 0 || x >= W;
  }  

  int n;
  vector<int> v;

  // int ans() {
  // }

  void solve() {
    cin >> n;
    v.resize(n);
    rep(i, n) cin >> v[i];

    map<int, int> m[2];
    rep(i, n) {
      m[i % 2][v[i]] += 1;
    }
    
    vector<pair<int, int>> v2[2];

    rep(i, 2) v2[i].push_back({0, 0});
    rep(i, 2) {
      for (auto& p : m[i]) {
        dump(p.first); dumpl(p.second);
        v2[i % 2].push_back({p.second, p.first});
      }
    }
    rep(i, 2) sort(all(v2[i]));


    pair<int, int> a[2];

    dumpl(v2[0].rbegin()->second);
    if (v2[0].rbegin()->second != v2[1].rbegin()->second) {
      a[0] = *v2[0].rbegin();
      a[1] = *v2[1].rbegin();
    }
    else {
      auto itr_b = v2[0].rbegin();
      itr_b++;
      pair<int, int> b = *itr_b;

      auto itr_c = v2[1].rbegin();
      itr_c++;
      pair<int, int> c = *itr_c;
      
      auto b_diff = abs(v2[0].rbegin()->first - b.first);
      auto c_diff = abs(v2[1].rbegin()->first - c.first);

      if (b_diff < c_diff) {
        a[0] = b;
        a[1] = *v2[1].rbegin();
      }
      else {
        a[0] = *v2[1].rbegin();
        a[1] = c;
      }
    }


    // rep(i, 2) {
    //   a[i] = *(m[i].begin()); 
    //   for (auto p : m[i]) {
    //     if (p.second > a[i].second) a[i] = p;
    //   }
    // }

    int res = 0;
    rep(i, 2) {
      dumpl(i);
      for (auto p : v2[i]) {
        dump(p.second);
        dump(a[i].second);
        dumpl(p.first);
        if (p.second != a[i].second) res += p.first;
      }
    }
    cout << res << endl;

  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


Measured memory_bytes: 9592