//https://ncode.syosetu.com/n4830bu/290/ #include using namespace std; int main() { int N; string S; cin >> N >> S; cout << (N >= 4 || S[0] == S[1] || (N == 3 && S[1] == S[2]) ? "YES" : "NO") << endl; }