there city compose n x n block block contain single building shape like vertical square prism you give 0indexed n x n integer matrix grid gridrc represent height building locate block row r column cA city skyline outer contour form building view city distance the skyline cardinal direction north east south west differentWe allow increase height number building different building the height 0height building increase however increase height building affect citys skyline cardinal directionreturn maximum total sum height building increase change city skyline cardinal direction Example 1input grid 3084245792630310output 35explanation the building height show center imageThe skyline view cardinal direction draw redthe grid increase height building affect skyline isgridNew 8 4 8 7 7 4 7 7 9 4 8 7 3 3 3 3 example 2input grid 000000000output 0explanation increase height building result skyline change Constraintsn gridlengthn gridrlength2 n 500 gridrc 100