#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(1);
  cin >> a[0];
  for (int i = 1, x; i < n; ++i) {
    cin >> x;
    if (a.back() != x) a.push_back(x);
  }
  n = (int)a.size();
  vector<vector<int>> dp(n, vector<int>(n));
  for (int len = 2; len <= n; ++len) {
    for (int i = 0, j = len - 1; j < n; ++i, ++j) {
      if (a[i] == a[j]) {
        dp[i][j] = dp[i + 1][j - 1] + 1;
      } else {
        dp[i][j] = min(dp[i + 1][j], dp[i][j - 1]) + 1;
      }
    }
  }
  cout << dp[0][n - 1] << endl;
  return 0;
}
