#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int N; string S; const string YES = "YES", NO = "NO"; string solve(){ if(S.find("11") != string::npos)return YES; if(S.find("00") != string::npos)return YES; if(sz(S) > 3)return YES; return NO; } int main(){ ios::sync_with_stdio(0); cin.tie(0); while(cin >> N >> S){ cout << solve() << endl; } }