//	created : 15/12/30
// 	autor   : Rp7rf
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>

using namespace std;
#define rep(i,a) for(long long i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(long longs i = a ; i < b ; i ++)
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
int main(void){
	ll n,in;
	while(cin>>n,n){
		cin>>in;
		vector<pii> v;
		v.pb(mp(in,1));
		ll input = n;
		while(--input){
			cin>>in;
			if(v[v.size()-1].first == in){
				v[v.size()-1].s ++;
			}else{
				v.pb(mp(in,1));
			}
		}
		ll ret = n;
		rep(i,v.size()){
				ll now = n;
				ll l = i - 1 , r = i + 1;
				while(0 <= l && r < v.size()){
					if(v[l].s + v[r].s >= 4 && v[l].f == v[r].f){
						now = now - (v[l].s + v[r].s);
					}else{
						break;
					}
					l --; r ++;
				}
				if(now != n)now -=v[i].s;
				ret = min(ret,now);
			
			//cout<<v[i].f<<" "<<v[i].s<<endl;
		}
		cout<<ret<<endl;
	}
}