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.length == 1 && eg.length == 1)
    {
        if (og[0][0] == eg[0][0]) writeln(n / 2);
        else 0.writeln;
    }
    else
    {
        if (og[0][0] == eg[0][0])
        {
            if (og.length == 1)
                writeln(n / 2 - eg[1][1]);
            else if (eg.length == 1)
                writeln(n / 2 - og[1][1]);
            else
                min(n/2-og[1][1], n/2-eg[1][1]).writeln;
        }
        else
        {
            writeln(n - og[0][1] - eg[0][1]);
        }
    }
}

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;