#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 10;
int num[MAXN], b[MAXN];
int dp[MAXN][MAXN];
int main() {
  int N = 0, cnt, x;
  scanf("%d", &cnt);
  for (int i = 1; i <= cnt; i++) {
    scanf("%d", &x);
    if (x != num[N]) num[++N] = x;
  }
  int E = N;
  for (int i = 1; i <= N; i++) {
    b[E--] = num[i];
  }
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) {
      if (num[i] == b[j])
        dp[i][j] = dp[i - 1][j - 1] + 1;
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  int ans = N - (dp[N][N] + 1) / 2;
  printf("%d\n", ans);
  return 0;
}
