#!/usr/bin/env python3 n = int(input()) x = sorted([int(x) for x in input().split()]) t = [] for i in range(len(x) - 1): t.append(x[i + 1] - x[i]) print("YES" if len(set(t)) == 1 and t[0] != 0 else "NO")