local mmi = math.min
local n = io.read("*n")
local c_term, c_thru = {}, {}
local edge = {}
local parent = {}
local childcnt = {}
for i = 1, n do
  c_term[i] = 0
  c_thru[i] = io.read("*n")
  edge[i] = {}
  parent[i] = -1
  childcnt[i] = 0
end
for i = 1, n - 1 do
  local a, b = io.read("*n", "*n")
  table.insert(edge[a], b)
  table.insert(edge[b], a)
end
parent[1] = 0
local tasks = {1}
for i = 1, n do
  local src = tasks[i]
  for j = 1, #edge[src] do
    local dst = edge[src][j]
    if parent[dst] == -1 then
      parent[dst] = src
      childcnt[src] = childcnt[src] + 1
      table.insert(tasks, dst)
    end
  end
end
tasks = {}

if childcnt[1] == 1 then
  c_term[1], c_thru[1] = c_thru[1], 0
end
for i = 2, n do
  if childcnt[i] == 0 then
    c_term[i], c_thru[i] = c_thru[i], 0
    table.insert(tasks, i)
  end
end
local valid = true
for i = 1, n - 1 do
  local c = tasks[i]
  local p = parent[c]
  if c_term[p] + c_thru[p] < c_term[c] then
    valid = false
    break
  end
  local sub = mmi(c_term[c], c_thru[p])
  c_term[c] = c_term[c] - sub
  c_thru[p] = c_thru[p] - sub
  c_term[p] = c_term[p] + sub - c_term[c]
  c_term[c] = 0
  childcnt[p] = childcnt[p] - 1
  if 0 == childcnt[p] then
    if 0 < c_thru[p] then
      valid = false
      break
    end
    table.insert(tasks, p)
  end
end
if c_term[1] + c_thru[1] ~= 0 then valid = false end
print(valid and "YES" or "NO")
