#include <bits/stdc++.h>
using namespace std;
const int maxN = 5050;
int n;
int ahorro[maxN][maxN];
vector<int> forwr(1), backw;
int main() {
  cin >> n;
  int aux;
  for (int i = 0; i < n; i++) {
    cin >> aux;
    if (aux != forwr.back()) forwr.push_back(aux);
  }
  n = forwr.size() - 1;
  backw = forwr;
  reverse(backw.begin() + 1, backw.end());
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (forwr[i] == backw[j])
        ahorro[i][j] = ahorro[i - 1][j - 1] + 1;
      else
        ahorro[i][j] = max(ahorro[i - 1][j], ahorro[i][j - 1]);
    }
  }
  cout << (n - ((ahorro[n][n] + 1) >> 1)) << endl;
  return 0;
}
