Task B-1.5. Marko and his "band" set off on a tour. On the first day, they headed east, on the second day, they continued north, on the third day, they continued west, on the fourth day, they headed south, on the fifth day, they headed east, and so on. If on the n-th day of the tour they walked $\frac{n^{2}}{2}$ kilometers, how many km were they from the starting point at the end of the fortieth day?