import Data.Array
import Control.Monad
import Data.Maybe
import Data.Either

data Item = Item { _x :: Integer, _y:: Integer, _t:: String } deriving Show

data MinMax = MinMax { _min :: Integer, _max:: Integer } deriving Show
data MinMax2 = MinMax2 { _mmx::MinMax, _mmy::MinMax } deriving Show
data MinMaxs = MinMaxs { _r::MinMax2, _l::MinMax2, _u::MinMax2, _d::MinMax2 } deriving Show

getMinMax2 ::Integer -> Integer -> MinMax2 -> MinMax2
getMinMax2 x y minmax2 =   
    MinMax2 (MinMax min_x max_x) (MinMax min_y max_y)
    where 
        min_x = min x $ (_min._mmx) minmax2
        max_x = max x $ (_max._mmx) minmax2
        min_y = min y $ (_min._mmy) minmax2
        max_y = max y $ (_max._mmy) minmax2

getMinMax :: Item -> MinMaxs -> MinMaxs

getMinMax (Item { _x = _x, _y = _y, _t = "R" }) minmaxs = MinMaxs (getMinMax2 _x _y (_r minmaxs)) (_l minmaxs) (_u minmaxs) (_d minmaxs)
getMinMax (Item { _x = _x, _y = _y, _t = "L" }) minmaxs = MinMaxs (_r minmaxs) (getMinMax2 _x _y (_l minmaxs)) (_u minmaxs) (_d minmaxs)
getMinMax (Item { _x = _x, _y = _y, _t = "U" }) minmaxs = MinMaxs (_r minmaxs) (_l minmaxs) (getMinMax2 _x _y (_u minmaxs)) (_d minmaxs)
getMinMax (Item { _x = _x, _y = _y, _t = "D" }) minmaxs = MinMaxs (_r minmaxs) (_l minmaxs) (_u minmaxs) (getMinMax2 _x _y (_d minmaxs))

subMinMax :: MinMax -> Integer
subMinMax mm =
    let MinMax _min _max = mm in
    2 * (_max - _min)

mergeMinMax :: MinMax -> MinMax -> MinMax
mergeMinMax mm1 mm2 =
    MinMax (min (_min mm1) (_min mm2)) (max (_max mm1) (_max mm2))

maybeMinMax :: MinMax -> Maybe MinMax
maybeMinMax mm
    | (_min mm) <= (_max mm) = Just mm
    | otherwise = Nothing

ketsugou :: Maybe a -> Maybe a -> Maybe a
ketsugou mm1 mm2 = if (isJust mm1) then mm1 else mm2

getLeft :: Either a b -> Maybe a
getLeft = either Just (const Nothing)

getRight :: Either a b -> Maybe b
getRight = either (const Nothing) Just 

-- data Times = Pattern1 ((Integer,Integer,Integer,Integer),(Integer,Integer,Integer,Integer,Integer)) | Pattern2 ((Integer,Integer),(Integer,Integer,Integer))  | Pattern3 Integer deriving Show

calcTime :: Maybe MinMax -> Maybe MinMax -> Maybe MinMax -> (Integer, Maybe ((Integer,Integer),(Integer,Integer),Maybe((Integer,Integer),(Integer,Integer))))

-- i : increment
-- d : decrement
-- c : constant
calcTime (Just mmi) (Just mmd) (Just mmc) =    
    (h3_x2, Just((t23_x2, t34_x2),(h2_x2, h4_x2),  Just((t12_x2, t45_x2),(h1_x2, h5_x2))))
    where

        MinMax i_min i_max = mmi
        MinMax c_min c_max = mmc
        MinMax d_min d_max = mmd

        ic_min_x2 = 2 * (c_min - i_min)
        cd_min_x2 = 2 * (d_min - c_min)
        id_min_x2 = d_min - i_min

        cd_max_x2 = 2 * (d_max - c_max)
        ic_max_x2 = 2 * (c_max - i_max)
        id_max_x2 = d_max - i_max

        tmin1_x2 = min ic_min_x2 id_min_x2
        tmin2_x2 = max id_min_x2 cd_min_x2
        tmax1_x2 = min cd_max_x2 id_max_x2
        tmax2_x2 = max id_max_x2 ic_max_x2

        h1_x2 = 2 * ( d_max - i_min )

        h2_x2 = if tmin1_x2 < tmax1_x2
                    then 
                        if tmin1_x2 < tmin2_x2
                        then
                            2 * (d_max - c_min) 
                        else
                            (2 * d_max) - (i_min + d_min)
                    else 
                        if tmax1_x2 < tmax2_x2
                        then
                            2 * (c_max - i_min)
                        else
                            (i_max + d_max) - (2 * i_min)

        h3_x2 = if tmin2_x2 < tmax1_x2
                    then 
                        2 * (d_max - d_min) 
                    else 
                        if tmax2_x2 < tmin1_x2
                        then
                            2 * (i_max - i_min) 
                        else
                            if tmin1_x2 < tmin2_x2
                            then
                                if tmax1_x2 < tmax2_x2
                                then
                                    2 * (c_max - c_min) 
                                else
                                    (i_max + d_max) - 2 * c_min
                            else
                                if tmax1_x2 < tmax2_x2
                                then
                                    2 * c_max - (i_min + d_min)
                                else
                                    (i_max + d_max) - (i_min + d_min)

        h4_x2 = if tmin2_x2 < tmax2_x2
                    then 
                        if tmax1_x2 < tmax2_x2
                        then
                            2 * (c_max - d_min ) 
                        else
                            (i_max + d_max) - (2 * d_min) 
                    else 
                        if tmin1_x2 < tmin2_x2
                        then
                            2 * (i_max -  c_min)
                        else
                            (2 * i_max) - (i_min + d_min)

        h5_x2 = 2 * ( i_max - d_min ) 

        t12_x2 = minimum [ic_min_x2, id_min_x2, cd_max_x2, id_max_x2]
        t23_x2 = min (max tmin1_x2 tmax1_x2) (min tmin2_x2 tmax2_x2)
        t34_x2 = max (max tmin1_x2 tmax1_x2) (min tmin2_x2 tmax2_x2)
        t45_x2 = maximum [id_min_x2, cd_min_x2, id_max_x2, ic_max_x2]

calcTime (Just mmi) (Just mmd) Nothing =    
    (h3_x2, Just((t23_x2, t34_x2),(h2_x2, h4_x2),  Just((t12_x2, t45_x2),(h1_x2, h5_x2))))
    where

        MinMax i_min i_max = mmi
        MinMax d_min d_max = mmd

        id_min_x2 = d_min - i_min

        id_max_x2 = d_max - i_max

        h1_x2 = 2 * ( d_max - i_min )

        h2_x2 = if id_min_x2 < id_max_x2
                    then 
                        (2 * d_max) - (i_min + d_min)
                    else 
                        (i_max + d_max) - (2 * i_min)

        h3_x2 = if id_min_x2 < id_max_x2
                    then 
                        2 * (d_max - d_min) 
                    else 
                        if id_max_x2 < id_min_x2
                        then
                            2 * (i_max - i_min) 
                        else
                            2 * ((i_max + d_max) - (i_min + d_min)) 

        h4_x2 = if id_min_x2 < id_max_x2
                    then 
                        (i_max + d_max) - (2 * d_min) 
                    else 
                        (2 * i_max) - (i_min + d_min)

        h5_x2 = 2 * ( i_max - d_min ) 

        t12_x2 = min id_min_x2 id_max_x2
        t23_x2 = min id_min_x2 id_max_x2

        t34_x2 = max id_min_x2 id_max_x2
        t45_x2 = max id_min_x2 id_max_x2

calcTime (Just mmi) Nothing (Just mmc) =    
    (h3_x2, Just((t23_x2, t34_x2),(h2_x2, h4_x2),Nothing))
    where

        MinMax i_min i_max = mmi
        MinMax c_min c_max = mmc

        ic_min_x2 = 2 * (c_min - i_min)
        ic_max_x2 = 2 * (c_max - i_max)

        h2_x2 = 2 * (c_max - i_min)

        h3_x2 = if ic_min_x2 < ic_max_x2
                then
                    2 * (c_max - c_min)
                else
                    2 * (i_max - i_min)

        h4_x2 =  2 * (i_max -  c_min)

        t23_x2 = min ic_min_x2 ic_max_x2

        t34_x2 = max ic_min_x2 ic_max_x2

calcTime Nothing (Just mmd) (Just mmc) =    
    (h3_x2, Just((t23_x2, t34_x2),(h2_x2, h4_x2),Nothing))
    where

        MinMax c_min c_max = mmc
        MinMax d_min d_max = mmd

        cd_min_x2 = 2 * (d_min - c_min)
        cd_max_x2 = 2 * (d_max - c_max)

        h2_x2 = 2 * (d_max - c_min)

        h3_x2 = if cd_min_x2 < cd_max_x2
                then
                    2 * (d_max - d_min)
                else
                    2 * (c_max - c_min)

        h4_x2 =  2 * (c_max -  d_min)

        t23_x2 = min cd_max_x2 cd_min_x2

        t34_x2 = max cd_max_x2 cd_min_x2

calcTime Nothing (Just mmd) Nothing =    
    (result,Nothing)
    where

        MinMax d_min d_max = mmd

        result = 2 * (d_max - d_min)

calcTime Nothing Nothing (Just mmc) =    
    (result,Nothing)
    where

        MinMax c_min c_max = mmc

        result = 2 * (c_max - c_min)

calcTime (Just mmi) Nothing Nothing =    
    (result,Nothing)
    where

        MinMax i_min i_max = mmi

        result = 2 * (i_max - i_min)

--calcTime :: Maybe MinMax -> Maybe MinMax -> Maybe MinMax -> (Integer, Maybe ((Integer,Integer),(Integer,Integer),Maybe((Integer,Integer),(Integer,Integer))))

getFunc :: (Integer, Maybe ((Integer,Integer),(Integer,Integer),Maybe((Integer,Integer),(Integer,Integer)))) -> Integer -> Integer
getFunc neta =
    let (h3,times) = neta in if isNothing times
    then
        const h3
    else
        let Just ((t23,t34),(h2,h4),m) = times in
        let func1 = \t -> 
                if t < t23
                then
                    h2 - t
                else
                    if t34 < t
                    then
                        h4 + t
                    else
                        h3 in
        if isNothing m
        then
            func1
        else
            let Just ((t12,t45),(h1,h5)) = m in
                \t -> 
                    if t < t12
                    then
                        h1 - 2 * t
                    else
                        if t45 < t
                        then
                            h5 + 2 * t
                        else
                            func1 t

getTimes :: (Integer, Maybe ((Integer,Integer),(Integer,Integer),Maybe((Integer,Integer),(Integer,Integer)))) -> [Integer]
getTimes neta =
    let (h3,times) = neta in if isNothing times
    then
        []
    else
        let Just ((t23,t34),(h2,h4),m) = times in
        if isNothing m
        then
            [t23,t34]
        else
            let Just ((t12,t45),(h1,h5)) = m in
                [t12,t23,t34,t45]

main :: IO()
main = do

    n <- (read :: String -> Int)  <$> getLine

    arr <- map words <$> replicateM n getLine

    let arr2 = do 
        [x, y, d] <- arr
        let x' = (read :: String -> Integer) x
        let y' = (read :: String -> Integer) y
        return $ Item x' y' d

    let initMinMax  = MinMax 200000000 (-200000000)

    let initMinMax2 = MinMax2 initMinMax initMinMax

    let seed = MinMaxs initMinMax2 initMinMax2 initMinMax2 initMinMax2

    let MinMaxs { _r = _r, _l = _l, _u = _u, _d = _d } = foldr getMinMax seed arr2

    let r_mmx = maybeMinMax $ _mmx _r

    let l_mmx = maybeMinMax $ _mmx _l

    let rl_mmy = maybeMinMax $ mergeMinMax (_mmy _r) (_mmy _l)

    let u_mmy = maybeMinMax $ _mmy _u

    let d_mmy = maybeMinMax $ _mmy _d

    let ud_mmx = maybeMinMax $ mergeMinMax (_mmx _u) (_mmx _d)

    let x_neta = calcTime r_mmx l_mmx ud_mmx

    let y_neta = calcTime u_mmy d_mmy rl_mmy 

    let xFunc = getFunc x_neta
    let yFunc = getFunc y_neta
    let xTimes = getTimes x_neta
    let yTimes = getTimes y_neta

    let xResults = map (\t -> (t,(xFunc t)*(yFunc t))) xTimes
    let yResults = map (\t -> (t,(xFunc t)*(yFunc t))) yTimes

    let results = concat [xResults, yResults]

    let result_zero =   xFunc(0) * yFunc(0)

    print $ (/4) $ (realToFrac :: Integer -> Double) $ minimum $ (result_zero :) $ map snd $ filter ((0<=).fst) $  results
    

Measured memory_bytes: 174460