void main()
{
    long n = readln.chomp.to!long;
    long[] v = readln.split.to!(long[]);

    long[] odd = v.stride(2).array;
    auto og = odd.sort!"a < b".group.array;
    og.sort!((x, y) => x[1] > y[1]);

    long[] even = v[1..$].stride(2).array;
    auto eg = even.sort!"a < b".group.array;
    eg.sort!((x, y) => x[1] > y[1]);

    if (og[0][0] == eg[0][0])
    {
        if (og.length == 1 && eg.length == 1)
            writeln(n / 2);
        else if (og.length == 1)
            writeln(n / 2 - eg[1][1].to!long);
        else if (eg.length == 1)
            writeln(n / 2 - og[1][1].to!long);
        else
            min(
                n-og[0][1].to!long-eg[1][1].to!long,
                n-og[1][1].to!long-eg[0][1].to!long
            ).writeln;
    }
    else
    {
        writeln(n - og[0][1].to!long - eg[0][1].to!long);
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;