#include <ios>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, b, l, i = 0, j = 0;
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
while (cin >> l) {
if (j >= n) {
j = 0;
i++;
}
if ((i > 0) && (j < i) && (l != 0)) {
cout << "NO" << endl;
return 0;
}
//cout <<j << " " << i <<endl;
j++;
}
cout << "YES" << endl;
}
// 64 位输出请用 printf("%lld")



京公网安备 11010502036488号