Problem 4. Let

be a positive integer. The integers from

to

are written in the cells of an

table (one integer per cell) so that each of them appears exactly once in each row and exactly once in each column. Denote by

the number of pairs

of numbers in the

row
(
), such that
, but

is written to the left of

(not necessarily next to it). Denote by

the number of pairs

of numbers in the

column
(
), such that
, but

is written above

(not necessarily next to it). Determine the largest possible value of the sum
![\[
r_1 + r_2 + \cdots + r_n + c_1 + c_2 + \cdots + c_n.
\]](//latex.artofproblemsolving.com/f/f/b/ffba47dc58af7d89930037e87c9c682769d887ee.png)
Note: In the nxn table we label the rows 1 to n from top to bottom, and we label the columns 1 to n from left to right.