import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); char[] arr = br.readLine().toCharArray(); for (int i = 1; i < arr.length; i++) { if (arr[i] == arr[i - 1]) { System.out.println("YES"); return; } } if (arr.length >= 4) { System.out.println("YES"); } else { System.out.println("NO"); } } }