#include <bits/stdc++.h>
using namespace std;
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2> &p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
int64_t power(int64_t a, int64_t b) {
  int64_t ans = 1;
  int64_t k = a;
  while (b > 0) {
    if (b & 1) {
      ans *= k;
      ans %= 1000000007;
    }
    k = (k * k) % 1000000007;
    b = b >> 1;
  }
  return ans;
}
int64_t gcd(int64_t a, int64_t b) {
  if (a == 0) return b;
  if (b == 0) return a;
  return gcd(b, a % b);
}
int64_t add_mod(int64_t a, int64_t b, int64_t m) {
  return ((a % m) + (b % m)) % m;
}
int64_t sub_mod(int64_t a, int64_t b, int64_t m) {
  return ((a % m) - (b % m) + m) % m;
}
int64_t mul_mod(int64_t a, int64_t b, int64_t m) {
  return ((a % m) * (b % m)) % m;
}
void print(double val, int k) {
  cout << fixed << setprecision(k) << val << "\n";
}
int64_t toint(string s) {
  stringstream ss;
  ss << s;
  int64_t x;
  ss >> x;
  return x;
}
bool myComp(pair<int, int> &a, pair<int, int> &b) { return a < b; }
void solve() {
  int n;
  cin >> n;
  int one = 0;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] == 1) one++;
  }
  if (one == 0 || one == n) {
    cout << "0"
         << "\n";
    return;
  }
  int count = 0;
  vector<pair<int, int> > arr;
  for (int i = 1; i < n - 1; i++) {
    if (v[i] == 0) {
      if (v[i - 1] == 1 and v[i + 1] == 1) {
        arr.push_back({i - 1, i + 1});
      }
    }
  }
  sort(arr.begin(), arr.end(), myComp);
  for (int i = 0; i < arr.size();) {
    if (i + 1 < n) {
      if (arr[i].second == arr[i + 1].first) {
        count++;
        i += 2;
      } else {
        count++;
        i++;
      }
    }
  }
  cout << count << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
