func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, arr[1000], dp[1000][10];   int solve(int i, int flag) {     if (i >= n) return 0;     if (dp[i][flag] != -1) return dp[i][flag];     if (arr[i] == 0)       dp[i][flag] = 1 + solve(i + 1, 0);     else if (arr[i] == 1) {       if (flag == 0 || flag == 1) {         dp[i][flag] = min(solve(i + 1, 2), 1 + solve(i + 1, 0));       } else         dp[i][flag] = 1 + solve(i + 1, 0);     } else if (arr[i] == 2) {       if (flag == 0 || flag == 2) {         dp[i][flag] = min(1 + solve(i + 1, 0), solve(i + 1, 1));       } else         dp[i][flag] = 1 + solve(i + 1, 0);     } else {       if (flag == 0) {         dp[i][flag] =             min(solve(i + 1, 2), min(1 + solve(i + 1, 0), solve(i + 1, 1)));       } else if (flag == 1) {         dp[i][flag] = min(solve(i + 1, 2), 1 + solve(i + 1, 0));       } else {         dp[i][flag] = min(solve(i + 1, 1), 1 + solve(i + 1, 0));       }     }     return dp[i][flag];   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> arr[i];     memset(dp, -1, sizeof(dp));     cout << solve(0, 0) << endl;     return 0;   }   