#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ALL(x) (x).begin(),(x).end() #define RALL(x) (x).rbegin(), (x).rend() #define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--) #define repp(i,n) for(int (i)=1;(i)<=(n);(i)++) #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--) #define clr(a) memset((a), 0 ,sizeof(a)) typedef pair P; typedef vector > pii; typedef map mi; int main(){ int n; string s; cin >> n >> s; if(n>3) cout << "YES" << endl; else if(n==1) cout << "NO" << endl; else if(s=="00"|| s=="11") cout << "YES" << endl; else if(s=="000" || s=="001" || s=="100" || s=="111" || s=="110" || s=="011") cout << "YES" << endl; else cout << "NO" << endl; return 0; }