#include #include int main(){ int N; char S[1000000]; scanf("%d",&N); scanf("%s",S); if(N<=2){ if(strcmp(S,"00")*strcmp(S,"11")==0) printf("YES\n"); else printf("NO\n"); } else if(strcmp(S,"101")*strcmp(S,"010")==0){ printf("NO\n"); } else{ printf("YES\n"); } return 0; }