Given a two-dimensional array of integers and a string "N", "E", "S", "W", return the sum of all elements on the border in the given compass direction.