The cells of an $n \times n$ table are filled with the numbers $1,2,\dots,n$ for the first row, $n+1,n+2,\dots,2n$ for the second, and so on until $n^2-n,n^2-n+1,\dots,n^2$ for the $n$-th row. Peter picks $n$ numbers from this table such that no two of them lie on the same row or column. Peter then calculates the sum $S$ of the numbers he has chosen. Prove that Peter always gets the same number for $S$, no matter how he chooses his $n$ numbers.
1. **Define the table and the problem setup:**
   The table is an \( n \times n \) grid where the cells are filled with numbers in the following manner:
   - The first row contains \( 1, 2, \ldots, n \).
   - The second row contains \( n+1, n+2, \ldots, 2n \).
   - This pattern continues until the \( n \)-th row, which contains \( n^2 - n + 1, n^2 - n + 2, \ldots, n^2 \).

2. **Define the numbers Peter picks:**
   Peter picks \( n \) numbers such that no two numbers are in the same row or column. Let these numbers be \( x_1, x_2, \ldots, x_n \), where \( x_i \) is the number picked from the \( i \)-th row.

3. **Express the numbers in terms of their positions:**
   Each number \( x_i \) in the \( i \)-th row can be written as:
   \[
   x_i = (i-1)n + c_i
   \]
   where \( c_i \) is the column number of \( x_i \) in the \( i \)-th row. Since \( x_i \) is in the \( i \)-th row and \( c_i \)-th column, \( c_i \) ranges from 1 to \( n \).

4. **Sum the numbers Peter picks:**
   The sum \( S \) of the numbers Peter picks is:
   \[
   S = \sum_{i=1}^n x_i = \sum_{i=1}^n \left( (i-1)n + c_i \right)
   \]
   Simplify the sum:
   \[
   S = \sum_{i=1}^n (i-1)n + \sum_{i=1}^n c_i
   \]
   The first sum is:
   \[
   \sum_{i=1}^n (i-1)n = n \sum_{i=1}^n (i-1) = n \left( \frac{(n-1)n}{2} \right) = \frac{(n-1)n^2}{2}
   \]
   The second sum is the sum of the column indices \( c_i \), which are a permutation of \( 1, 2, \ldots, n \):
   \[
   \sum_{i=1}^n c_i = 1 + 2 + \cdots + n = \frac{n(n+1)}{2}
   \]

5. **Combine the results:**
   Therefore, the total sum \( S \) is:
   \[
   S = \frac{(n-1)n^2}{2} + \frac{n(n+1)}{2}
   \]
   Simplify the expression:
   \[
   S = \frac{(n-1)n^2 + n(n+1)}{2} = \frac{n^3 - n^2 + n^2 + n}{2} = \frac{n^3 + n}{2} = \frac{n(n^2 + 1)}{2}
   \]

6. **Conclusion:**
   The sum \( S \) is always \( \frac{n(n^2 + 1)}{2} \), regardless of how Peter chooses the \( n \) numbers.

The final answer is \( \boxed{\frac{n(n^2 + 1)}{2}} \).