In a $n\times n$ table ($n>1$) $k$ unit squares are marked.One wants to rearrange rows and columns so that all the marked unit squares are above the main diagonal or on it.For what maximum $k$ is it always possible?
1. **Base Case:**
   - For \( n = 2 \), we need to show that it is possible to rearrange the rows and columns such that all marked squares are on or above the main diagonal if \( k \leq 3 \).
   - If \( k = 3 \), we can mark the squares \((1,1)\), \((1,2)\), and \((2,2)\). This configuration already satisfies the condition.
   - Therefore, the base case holds.

2. **Inductive Step:**
   - Assume that for \( n = m \), it is possible to rearrange the rows and columns such that all marked squares are on or above the main diagonal if \( k \leq m + 1 \).
   - We need to show that for \( n = m + 1 \), it is possible to rearrange the rows and columns such that all marked squares are on or above the main diagonal if \( k \leq m + 2 \).

3. **Case 1: There is an empty row.**
   - If there is an empty row, switch that row with the bottom row.
   - Then, switch a column with at least one marked square with the rightmost column.
   - Consider the top left \( m \times m \) sub-table. The number of marked squares in this sub-table is \( \leq m + 1 \).
   - Since the bottom row is empty and the rightmost column won't affect the condition, by the induction hypothesis, it is possible to arrange the \( m \times m \) sub-table to satisfy the condition.
   - This arrangement will automatically make the \( (m + 1) \times (m + 1) \) table satisfy the condition.

4. **Case 2: There are no empty rows.**
   - If there are no empty rows, there will be a row with exactly one marked square.
   - Switch this row with the bottom row.
   - Then, switch the column containing this marked square with the rightmost column.
   - By the induction hypothesis, it is possible to arrange the \( m \times m \) sub-table to satisfy the condition.
   - This arrangement will automatically make the \( (m + 1) \times (m + 1) \) table satisfy the condition.

5. **Proof that \( k = n + 1 \) is the maximum:**
   - For \( k = n + 2 \), mark the squares on the main diagonal and the other two corner squares.
   - No matter how the rows and columns are rearranged, there will always be two rows and columns with two marked squares, and \( n - 2 \) rows and columns with one marked square.
   - This configuration makes it impossible to have all marked squares on or above the main diagonal, leading to a contradiction.

The final answer is \( \boxed{ n + 1 } \)