import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class No406 { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] str = br.readLine().split(" "); int[] nums = new int[n]; for(int i=0; i < n; i++) nums[i] = Integer.parseInt(str[i]); Arrays.sort(nums); int difference = nums[1] - nums[0]; int count = 0; if(difference != 0){ for(int i=1; i< n-1; i++) if((nums[i+1] - nums[i]) == difference){ count++; } } if(count == n-2) System.out.println("YES"); else System.out.println("NO"); } }