#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
vector<int> fir;
vector<int> sec;
int dp[N][N];
int main() {
  int n;
  scanf("%d", &n);
  int tmp;
  while (n--) {
    scanf("%d", &tmp);
    if (fir.empty() || fir.back() != tmp) fir.push_back(tmp);
  }
  sec = fir;
  reverse(sec.begin(), sec.end());
  fir.insert(fir.begin(), 0);
  sec.insert(sec.begin(), 0);
  for (int i = 1; i < fir.size(); i++) {
    for (int j = 1; j < sec.size(); j++) {
      dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      if (fir[i] == sec[j]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
    }
  }
  printf("%d\n", sec.size() - 2 - dp[fir.size() - 1][sec.size() - 1] / 2);
}
