#include using namespace std; #define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) lp(i, 0, n) #define rlp(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--) #define rrep(i, n) rlp(i, 0, n) #define mp make_pair #define mt make_tuple #define pb push_back #define eb emplace_back #define all(c) begin(c), end(c) typedef long long ll; typedef unsigned long long ull; template inline void unique(T &c){ sort(all(c)); c.erase(unique(all(c)), end(c)); } int n; string s; int main() { cin >> n >> s; rep(i, n - 1){ if (s[i] == s[i + 1]){ cout << "YES\n"; return 0; } } rep(i, n - 3){ bool t = string(s, i, 4) == "1010" | string(s, i, 4) == "0101"; if (t){ cout << "YES\n"; return 0; } } cout << "NO\n"; }