#include <bits/stdc++.h>
using namespace std;
int n;
int a[4], cnt[4];
int main() {
  scanf("%d", &n);
  if (n % 3 != 0) return puts("NO");
  for (int i = 1; i <= 3; ++i) {
    scanf("%d", &a[i]);
    cnt[i] = 1;
  }
  if (a[1] ^ a[2] != a[3] && a[1] ^ a[3] != a[2] && a[2] ^ a[3] != a[1])
    return puts("NO");
  for (int i = 4; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    for (int j = 1; j <= 3; ++j)
      if (a[i] == x && cnt[j] + 1 <= n / 3) {
        ++cnt[j];
        break;
      }
  }
  for (int i = 1; i <= 3; ++i)
    if (cnt[i] != n / 3) return puts("NO");
  puts("YES");
  return 0;
}
