#include #include #include #include #include #include #include #include #define FOR(i, a, b) for(int i=(a);i<=(b);i++) #define RFOR(i, a, b) for(int i=(a);i>=(b);i--) #define MOD 1000000007 using namespace std; int main(void) { int n; int *x; int point; bool flag = true; cin >> n; x = new int[n]; FOR(i, 0, n - 1) { cin >> x[i]; } point = abs(x[2] - x[0]); FOR(i, 1, n - 2) { if (abs(x[i - 1] - x[i + 1]) != point) { flag = false; break; } } sort(x, x + n ); FOR(i, 0, n - 2) { if (x[i] == x[i + 1]) { flag = false; break; } } if (flag) { cout << "YES" << endl; } else { cout << "NO" << endl; } delete[] x; return 0; }