#include void quickSort(int*, int, int); int main(void) { int b, i, t, n, a[100000]; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &a[i]); quickSort(a, 0, n - 1); b = 0; t = a[1] - a[0]; for (i = 0; i < n - 1; i++) { if (a[i] == a[i + 1] || a[i + 1] - a[i] != t) { b = -1; break; } } if (b == 0) printf("YES\n"); else printf("NO\n"); return 0; } void quickSort(int* data, int left, int right) { int l, r, temp, t; if (left >= right) return; temp = data[(left + right) / 2]; l = left; r = right; while (-1) { while (data[l] < temp) l++; while (data[r] > temp) r--; if (l >= r) break; t = data[l]; data[l] = data[r]; data[r] = t; l++; r--; } if (left < l - 1) quickSort(data, left, l - 1); if (right > r + 1) quickSort(data, r + 1, right); }