#include <bits/stdc++.h>
using namespace std;
vector<long long> x;
vector<vector<long long> > dp;
long long ans(long long i, long long j) {
  if (i == -1) {
    return (long long)x.size() - j;
  }
  if (j == (long long)x.size()) {
    return i + 1;
  }
  if (dp[i][j] != -1) {
    return dp[i][j];
  }
  if (x[i] == x[j]) {
    return dp[i][j] = 1 + ans(i - 1, j + 1);
  }
  return dp[i][j] = 1 + min(ans(i - 1, j), ans(i, j + 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long a;
  cin >> a;
  for (long long i = 0; i < a; i++) {
    long long k;
    cin >> k;
    x.push_back(k);
  };
  dp = vector<vector<long long> >(a + 1, vector<long long>(a + 1, -1));
  auto p = unique(x.begin(), x.end());
  x.resize(distance(x.begin(), p));
  long long z = INT_MAX;
  for (long long j = 0; j < (long long)x.size(); j++) {
    z = min(z, ans(j - 1, j + 1));
  }
  cout << z;
  return 0;
}
