n = int(input())
seats=input()
seats="0"+seats+"0"
if("11" in seats or "000" in seats):
print("NO")
else:
print("YES")
// Problem: A. Row
// Contest: Codeforces - Codeforces Round #484 (Div. 2)
// URL: https://codeforces.com/contest/982/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
/*
#WTFyouhere
♕ABHINAV♕
HUSTLE KARO BHASAD NHI.....
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
const unsigned int M = 1000000007;
//►►►►►►►►►►►►►►►►►►►►(⊙⊙)(☉_☉)(⊙⊙)►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►
ll power(ll a, ll b, ll m = M) {a %= m;ll res = 1;while (b > 0) {
if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
ll gcd(ll x, ll y) {return (x ? gcd(y % x, x) : y);}
ll inv(ll n, ll m = M) {return power(n, m - 2, m);}
ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
ll nextgreaterelement(ll n) {auto digits = to_string(n);
next_permutation(begin(digits), end(digits));auto res = stoll(digits);return res;}
vector<int> factorize(int n) {vector<int> ans;for (int i = 2; i * i <= n; ++i) {
while (n % i == 0) {ans.push_back(i);n /= i;}}if (n != 1) {ans.push_back(n);}
for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";}
ll near_pow(ll q){ll ans = (ll)log2(q);return pow(2,ans);}
long long ceil(long long p, long long q) {if(p % q == 0) return (p / q);return (p / q) + 1;}
//►►►►►►►►►►►►►►►►►►►(⊙⊙)(☉_☉)(⊙⊙)►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►
void reply()
{
ll t;
cin>>t;
while(t--)
{
}
}
int main() {
// your code goes here
//reply();
int n;
cin>>n;
string s;
cin>>s;
int count=0;
if(n==1)
{
if(s[0]=='1')cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
else if((s[0]==s[1]&&s[0]=='0')||(s[n-1]==s[n-2]&&s[n-1]=='0'))cout<<"No"<<endl;
else
{
int cz=0,co=0;
for(int i=0;i<n;i++)
{
if(i+1<n)
{
if(s[i]==s[i+1]&& s[i]=='1')
{
co++;
break;
}
else if(s[i]==s[i+1] && s[i]=='0')
{
cz++;
if(cz+1==3)break;
}
else
{
co=0;
cz=0;
}
}
}
if(co>0)cout<<"No"<<endl;
else if(cz+1==3)cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
}
1036D - Vasya and Arrays | 1139C - Edgy Trees |
37A - Towers | 353A - Domino |
409H - A + B Strikes Back | 1262A - Math Problem |
158C - Cd and pwd commands | 194A - Exams |
1673B - A Perfectly Balanced String | 1104B - Game with string |
1169B - Pairs | 1567D - Expression Evaluation Error |
78A - Haiku | 1287A - Angry Students |
1428A - Box is Pull | 234B - Reading |
581B - Luxurious Houses | 1481C - Fence Painting |
935A - Fafa and his Company | 22A - Second Order Statistics |
1720B - Interesting Sum | 1720A - Burenka Plays with Fractions |
3A - Shortest path of the king | 1720C - Corners |
574A - Bear and Elections | 352B - Jeff and Periods |
1244A - Pens and Pencils | 1670A - Prof Slim |
1189A - Keanu Reeves | 678A - Johny Likes Numbers |