int main(){ int n; char s[1000000]; int i,j; scanf("%d",&n); scanf("%s",s); if(n==1)printf("NO\n"); else if (n==2){ if(s[0]!=s[1]) printf("NO\n"); else printf("YES\n"); } else if(n==3){ if(s[0]=='0' && s[1]=='1' && s[2]=='0')printf("NO\n"); else if(s[0]=='1' && s[1]=='0' && s[2]=='1')printf("NO\n"); else printf("YES\n"); } else printf("YES\n"); return 0; }