import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean v1=true,v2=true,h=false; int pa=0,pb=0; for(int i=0; i0){ if(a!=pa) v1=false; if(b!=pb) v2=false; } pa =a; pb = b; } if(v1 || v2 || h) System.out.println("YES"); else System.out.println("NO"); } }