import java.util.Scanner; public class b { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int foo[] = new int[N]; for(int i = 0; i < N; i++) foo[i] = sc.nextInt(); int min = 114514810; int min2th = 364364893; for(int i = 1; i < N; i++){ if(foo[i] < min){ min2th = min; min = foo[i]; }else if(foo[i] < min2th){ min2th = foo[i]; } if(foo[i] < foo[i - 1]){ int tmp = foo[i]; foo[i] = foo[i - 1]; foo[i - 1] = tmp; }else if(foo[i] == foo[i - 1]){ System.out.println("NO"); return; } } int bar = min2th - min; if(bar == 0){ System.out.println("NO"); return; } for(int i = 0; i < N - 1; i++){ if(foo[i] + bar != foo[i + 1]){ System.out.println("NO"); return; } } System.out.println("YES"); } }