n = int(input()) s = input() ok = False for i in range(n - 2) : ok = ok or (s[i:i+3] == "404") print("Yes" if ok else "No")