#include using namespace std; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15); } } initializer; int main() { int n; string s; cin >> n >> s; cout << (n >= 4 || s.find("00") != string::npos || s.find("11") != string::npos ? "YES" : "NO") << endl; }