# !/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import Counter N = int(readline()) m = map(int, read().split()) degree = Counter(zip(m, m)).values() print('YES' if max(degree) <= 2 else 'NO')