#include using namespace std; namespace { typedef double real; typedef long long ll; template ostream& operator<<(ostream& os, const vector& vs) { if (vs.empty()) return os << "[]"; os << "[" << vs[0]; for (int i = 1; i < vs.size(); i++) os << " " << vs[i]; return os << "]"; } template istream& operator>>(istream& is, vector& vs) { for (auto it = vs.begin(); it != vs.end(); it++) is >> *it; return is; } int N; string S; void input() { cin >> N >> S; } bool C() { for (int i = 0; i < N - 1; i++) { if (S[i] == S[i + 1]) return true; } return N >= 4; } void solve() { cout << (C() ? "YES" : "NO") << endl; } } int main() { input(); solve(); return 0; }