@[yaoge2012](/user/1135416) 万一第一个数是2呢?
by hhhcj @ 2024-04-27 13:22:10
@[yaoge2012](/user/1135416) this:
```cpp
#include<iostream>
#include<cmath>
using namespace std;
int n,a[100];
//zs
int main(){
cin >> n;
cin >> a[1];
for (int i = 2; i <= n; i++) {
cin >> a[i];
if (abs (a[i] - a[i-1]) > 1) cout << "NO\n" , exit (0);
}
cout << "YES"<<endl;
return 0;
}
```
亲测AC。
by hhhcj @ 2024-04-27 13:24:04
@[hhhcj](/user/1021663) 感谢(能壶关吗?)
by yaoge2012 @ 2024-04-27 13:28:43
@[yaoge2012](/user/1135416) 已关
by hhhcj @ 2024-04-27 13:29:43