x=int(input())
p=input()
for i in range(x-2):
    # print(p[i:i+3],"".join(reversed(p[i:i+3])))
    if p[i:i+3]=="".join(reversed(p[i:i+3])):exit(print("YES"))
print("NO")

# My code says who am i
# I want to burn and born at this way
# In my eye there is not any things Except love ...
