#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } bool t=false; for (int i = 0; i < n; i++) { if ( (a[i]+ a[n-i-1]) == (a[0] + a[n-1]) ) { t=true; }else{ t=false; } } if (!t) { cout << "NO" << endl; }else{ cout << "YES" << endl; } return 0; }