#include #include using namespace std; int main() { int i = 0, a[100000]{0}, n = 0, f = 1, b = 0, d = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } while (f == 1) { f = 0; for (i = 0; i < n - 1; i++) { if (a[i] > a[i + 1]) { b = a[i]; a[i] = a[i + 1]; a[i + 1] = b; f = 1; } } } d = a[1] - a[0]; for (i = 0; i < n - 1; i++) { if ((a[i + 1] - a[i]) != d || d == 0) { f = 0; break; } if (i == (n - 2)) f = 1; } if (f == 1) cout << "YES" << endl; else cout << "NO" << endl; return 0; }