N = int(input())
S = input()
if N == 1:
    print('NO')
elif N == 2:
    if S[0] == S[1]:
        print('YES')
    else:
        print('NO')
elif N == 3:
    if S[0] == S[1] or S[1] == S[2]:
        print('YES')
    else:
        print('NO')
else:
    print('YES')