#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
vector<int> vc;
int memo[5001][5001];
int solve(int l, int r) {
  if (l >= r) return 0;
  if (memo[l][r] != -1) return memo[l][r];
  if (vc[l] == vc[r]) {
    return memo[l][r] = 1 + solve(l + 1, r - 1);
  } else {
    return memo[l][r] = min(1 + solve(l + 1, r), 1 + solve(l, r - 1));
  }
}
int main() {
  memset(memo, -1, sizeof(memo));
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  ;
  vc.push_back(a[0]);
  int last = a[0];
  for (int i = 1; i < n; ++i) {
    if (a[i] != last) {
      vc.push_back(a[i]);
      last = a[i];
    }
  }
  cout << solve(0, vc.size() - 1);
  return 0;
}
