#include <bits/stdc++.h>
using namespace std;
int c[5005], n, b[5005], dp[5005][5005];
int main() {
  cin >> n;
  int cnt = 0, x;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (x != c[cnt]) c[++cnt] = x;
  }
  for (int i = 1, j = cnt; i <= cnt; i++, j--) b[i] = c[j];
  for (int i = 1; i <= cnt; i++) {
    for (int j = 1; j <= cnt; j++) {
      if (c[i] == b[j])
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
      else
        dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1]));
    }
  }
  cout << cnt - (dp[cnt][cnt] + 1) / 2 << endl;
  return 0;
}
