import sys from functools import reduce import operator def input(): return sys.stdin.readline().rstrip('\n') def main(): input() s = input() print('NO' if len(s) < 4 and '00' not in s and '11' not in s else 'YES') if __name__ == '__main__': main()