#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
pair<int, int> getMaxAndMin(vector<int> numbers) {
  int maximum = -INF;
  int minimum = INF;
  for (int i = 0; i < numbers.size(); i++) {
    int nextNumber = numbers[i];
    maximum = max(maximum, nextNumber);
    minimum = min(minimum, nextNumber);
  }
  return make_pair(maximum, minimum);
}
set<int> getPossibleAnswers(pair<int, int> maxAndMin) {
  set<int> answers;
  answers.insert(maxAndMin.first);
  answers.insert(maxAndMin.second);
  int average = (maxAndMin.first + maxAndMin.second) / 2;
  answers.insert(average);
  return answers;
}
bool checkPossibleAnswer(vector<int> elements, int possibleAnswer) {
  int xNumber;
  bool isXNumberSet = false;
  for (int i = 0; i < elements.size(); i++) {
    int diffrence = abs(elements[i] - possibleAnswer);
    if (diffrence) {
      if (isXNumberSet) {
        if (xNumber != diffrence) {
          return false;
        }
      } else {
        xNumber = diffrence;
        isXNumberSet = true;
      }
    }
  }
  return true;
}
bool checkPossibleAnswers(vector<int> elements, set<int> possibleAnswers) {
  set<int>::iterator it;
  for (it = possibleAnswers.begin(); it != possibleAnswers.end(); it++) {
    if (checkPossibleAnswer(elements, *it)) {
      return true;
    }
  }
  return false;
}
bool solve(vector<int> elements) {
  pair<int, int> maxAndMin = getMaxAndMin(elements);
  set<int> possibleAnswers = getPossibleAnswers(maxAndMin);
  return checkPossibleAnswers(elements, possibleAnswers);
}
int main() {
  int numberOfElements;
  cin >> numberOfElements;
  vector<int> elements;
  for (int i = 0; i < numberOfElements; i++) {
    int nextElement;
    cin >> nextElement;
    elements.push_back(nextElement);
  }
  bool answer = solve(elements);
  if (answer) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
