class Node
  attr_accessor :child, :visited
  def initialize
    @child = {}
  end
end

def f(i, j, g)
  unless $known[i][j]
    max = 0
    g[j].child.each{|k, w|
      next if i == k
      ret = f(j, k, g)
      max = ret if max < ret
    }
    $known[i][j] = g[i].child[j] + max
  end
  return $known[i][j]
end


$known = Hash.new{|h, k| h[k] = {}}
n = gets.to_i
g = Array.new(n){Node.new}

(n-1).times{
  s, t, w = gets.split.map(&:to_i)
  g[s].child[t] = w
  g[t].child[s] = w
}

n.times{|i|
  max = 0
  g[i].child.each{|j, w|
    ret = f(i, j, g)
    max = ret if max < ret
  }
  puts max
}