#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ZERO(a) memset(a,0,sizeof(a))

int n;
int a[100010];

bool is_inRange(int l, int r) {
    return (1<=l and r<=n);
}

int calc(int p) {
    int ret = 0;
    int l = p, r = p;
    while(is_inRange(l,r)) {
        if(a[l] != a[r]) return ret;
        int cnt = 0 , t = a[l];
        if(l == r) cnt = -1;

        while(1 <= l and a[l] == t) l--, cnt++;
        while(r <= n and a[r] == t) r++, cnt++;
        if(cnt >= 4) ret += cnt;
    }

    return ret;
}

int main() {
    while(cin>>n && n) {
        ZERO(a);
        FOR(i,1,n+1) scanf("%d",&a[i]); // 1-indexed

        int cnt = -1;
        FOR(pos, 1, n+1) {
            int tmp = a[pos];
            FOR(color, 1, 4) {
                if(color == tmp) continue;
                a[pos] = color;
                cnt = max(cnt, calc(pos));
            }
            a[pos] = tmp;
        }

        printf("%d\n", n - cnt);
    }

    return 0;
}