#include <bits/stdc++.h>
using namespace std;
const int N = 5001;
long long mod = 1e9 + 7;
int power(int a, int p) {
  int r = 1, y = a;
  while (p) {
    if (p & 1) r = (1LL * r * y) % mod;
    p >>= 1;
    y = (1LL * y * y) % mod;
  }
  return r;
}
int dp[N][N][2];
int ara[N];
int n;
int call(int l, int r, int x) {
  if (l == 0 && r == n - 1) return 0;
  if (dp[l][r][x] != -1) return dp[l][r][x];
  int f1 = 1000000000, f2 = 1000000000;
  int temp;
  if (x == 0)
    temp = ara[l];
  else
    temp = ara[r];
  if (l > 0) {
    int a = 0;
    if (ara[l - 1] != temp) a = 1;
    f1 = a + call(l - 1, r, 0);
  }
  if (r < n - 1) {
    int a = 0;
    if (ara[r + 1] != temp) a = 1;
    f2 = a + call(l, r + 1, 1);
  }
  return dp[l][r][x] = min(f1, f2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ara[i];
  memset(dp, -1, sizeof dp);
  int ans = 1000000000;
  for (int i = 0; i < n; i++) {
    int temp = call(i, i, 0);
    ans = min(ans, temp);
  }
  cout << ans << endl;
}
