#include #include using namespace std; using ll = long long; #define int ll #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define ALL(a) (a).begin(), (a).end() template void chmax(t& a, u b) { if (a < b) a = b; } template void chmin(t& a, u b) { if (b < a) a = b; } template using vc = vector; template using vvc = vc>; using pi = pair; using vi = vc; using uint = unsigned; using ull = unsigned long long; int popcount(signed t) { return __builtin_popcount(t); } int popcount(ll t) { return __builtin_popcountll(t); } bool ispow2(int i) { return i && (i & -i) == i; } ll mask(int i) { return (ll(1) << i) - 1; } int lcm(int a, int b) { return a / __gcd(a, b) * b; } vector enum_divisors(int N) { vector res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.push_back(i); if (N / i != i) res.push_back(N / i); } } sort(res.begin(), res.end()); return res; } signed main() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); int n; cin >> n; vc a(n); set prime; rep(i, n) cin >> a[i]; set elem; rep(i, n) elem.insert(a[i]); if (elem.size() <= 2) { cout << "Yes" << endl; return 0; } // dを全探索したい int cnt = 0; vc b; rep(i, n) { if (a[i] == 0) cnt++; else { b.emplace_back(a[i]); } } vc ma = b; sort(ALL(ma)); if (cnt == 0) { bool ok = true; int x = ma[1] - ma[0]; rep(i, n - 1) if (ma[i + 1] - ma[i] != x) ok = false; if (ok) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; } bool same = false; rep(i, ma.size() - 1) { if (ma[i] == ma[i + 1]) same = true; } if (same) { rep(i, ma.size() - 1) { if (ma[i] != ma[i + 1]) { cout << "No" << endl; return 0; } } } for (int i = 0; i < b.size() - 1; i++) { int diff = ma[i + 1] - ma[i]; auto q = enum_divisors(diff); for (auto u : q) prime.insert(u); } vc d(ALL(prime)); int l = b.size(); for (auto v : d) { int tmp = 0; bool f = true; for (int i = 0; i < l - 1; i++) { int diff = ma[i + 1] - ma[i]; if (diff % v != 0) { f = false; } else { tmp += diff / v - 1; } } if (f && tmp <= cnt) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; }