import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int indexLength = scanner.nextInt(); int[] xValues = new int[indexLength]; boolean horz = true; for(int indexOne = 0; indexOne < indexLength; indexOne++){ int x = scanner.nextInt(); for (int indexTwo = 0; indexTwo < indexOne; indexTwo++) { if (x != xValues[indexTwo]) { horz = false; } xValues[indexOne] = x; } int y = scanner.nextInt(); } if (horz) { System.out.println("YES"); } else { System.out.println("NO"); } } }