#include <bits/stdc++.h>
const long long mod = 1e6 + 3;
using namespace std;
int g = 0;
int vis[10];
int a[100005];
int main() {
  int n;
  cin >> n;
  set<int> s;
  for (int i = 1; i <= n; i++) scanf("%d", a + i), s.insert(a[i]);
  int p = s.size();
  if (p <= 3) {
    if (p == 1) {
      printf("YES\n");
    } else if (p == 2) {
      int b[3];
      g = 0;
      for (set<int>::iterator it = s.begin(); it != s.end(); it++)
        g++, b[g] = (*it);
      for (int i = 1; i <= n; i++) {
        if (a[i] == b[1])
          vis[1]++;
        else
          vis[2]++;
      }
      printf("YES\n");
    } else if (p == 3) {
      int c[5];
      g = 0;
      for (set<int>::iterator it = s.begin(); it != s.end(); it++)
        g++, c[g] = (*it);
      sort(c + 1, c + 1 + g);
      for (int i = 1; i <= n; i++) {
        if (a[i] == c[1])
          vis[1]++;
        else if (a[i] == c[2])
          vis[2]++;
        else
          vis[3]++;
      }
      if ((c[1] + c[3]) == 2 * c[2])
        printf("YES\n");
      else
        printf("NO\n");
    }
  } else
    printf("NO\n");
}
