import Data.List
import Control.Monad
import Data.Set

data Axis = X|Y deriving Show
type City = [(Int,Int,Int)]
type RoadMap = [(Axis, Int)]

fst3 (x,y,z) = x
snd3 (x,y,z) = y

x -: f = f x

getInt = (fmap read) getLine :: IO Int
getInts = ((fmap ((fmap read) . words)) getLine) :: IO [Int]

getFromLines :: Int -> IO a -> IO [a]
getFromLines 0 _ = return []
getFromLines n getA = do
  a <- getA
  l <- getFromLines (n-1) getA
  return (a:l)

main = do
  n <- getInt
  city' <- getFromLines n getInts
  let city = fmap (\[x,y,w]->(x,y,w)) city'
  putStrLn $ [0..(n-1)] -: (fmap (\i-> show $ minCost i city)) -: (intercalate "\n")
  print 0

  --let (n,city) = (6, [(2,5,1000),(5,2,1100),(5,5,1700),(-2,-5,900),(-5,-2,600),(-5,-5,2200)])
  --putStrLn $ [0..(n-1)] -: (fmap (\i-> show $ minCost i city)) -: (intercalate "\n")
  --print $ ([0..(n-1)] -: (fmap (\i-> show $ minCost i city)) -: (intercalate "\n")) == "26700\n13900\n3200\n1200\n0\n0"


minCost :: Int -> City -> Int
minCost nRoad city =
  (roadCands city nRoad) -:
  (fmap (\roadMap-> calcCost city ((X,0):(Y,0):roadMap))) -:
  minimum

calcCost :: City -> RoadMap -> Int
calcCost city roadMap =
  city -: (fmap (cityMinCost roadMap)) -: sum
  where
  cityMinCost :: RoadMap -> (Int,Int,Int) -> Int
  cityMinCost roadMap (x,y,w) = w * (roadMap -: (fmap (distance (x,y))) -: minimum)
  distance:: (Int,Int) -> (Axis, Int) -> Int
  distance (x,y) (X, x') = abs (x-x')
  distance (x,y) (Y, y') = abs (y-y')

roadCands :: City -> Int -> [RoadMap]
roadCands city 0 = [[]]
roadCands [] nRoad = []
roadCands ((x,y,_):city') nRoad =
  (roadCands city' nRoad) ++
  ((roadCands city' (nRoad-1)) -: (fmap ((X,x):))) ++
  ((roadCands city' (nRoad-1)) -: (fmap ((Y,y):)))



chose :: [a] -> Int -> [[a]]
chose l 0 = [[]]
chose [] k = []
chose (x:xs) k = (chose xs k) ++ ((chose xs (k-1)) -: (fmap (x:)))
