#include <bits/stdc++.h>
using namespace std;
int dp[5001][5001][2];
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k < 2; k++) {
        dp[i][j][k] = ((i == j) ? 0 : (int)(1e9 + 7));
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j >= 1; j--) {
      for (int k = 0; k < 2; k++) {
        int cc = ((k == 0) ? a[j] : a[i]);
        if (j > 1)
          dp[j - 1][i][0] =
              min(dp[j - 1][i][0], dp[j][i][k] + (int)(a[j - 1] != cc));
        if (i < n)
          dp[j][i + 1][1] =
              min(dp[j][i + 1][1], dp[j][i][k] + (int)(a[i + 1] != cc));
      }
    }
  }
  cout << min(dp[1][n][0], dp[1][n][1]) << endl;
  return 0;
}
