#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int main() { int N; cin >> N; string S; cin >> S; for ( int i = 0; i < N-1; i++ ) { if ( S[i] == S[i+1] ) { cout << "YES" << endl; return 0; } } for ( int i = 0; i < N-3; i++ ) { if ( S.substr( i, 4 ) == "1010" || S.substr( i, 4 ) == "0101" ) { cout << "YES" << endl; return 0; } } cout << "NO" << endl; return 0; }