//  #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432
#include <algorithm>
#include <array>
#include <iostream>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);
  int x, n;
  array<int, 9> a{0};
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> x;
    a[x - 1]++;//---------计数,计算每个数字出现的次数
  }
  sort(a.begin(), a.end());
  if (a[8] - a[0] > 1)//--------如果出现次数最多的数字的出现次数 - 出现次数最少的数字的出现次数 > 1;就不能实现,否则只需将多出来的部分放在最前面就好了
    cout << "NO";
  else cout << "YES";
}
// 64 位输出请用 printf("%lld")