For $n$ distinct positive integers all their $n(n-1)/2$ pairwise sums are considered. For each of these sums Ivan has written on the board the number of original integers which are less than that sum and divide it. What is the maximum possible sum of the numbers written by Ivan?
We are given \( n \) distinct positive integers and we need to consider all their \( \frac{n(n-1)}{2} \) pairwise sums. For each of these sums, Ivan writes on the board the number of original integers which are less than that sum and divide it. We aim to find the maximum possible sum of the numbers written by Ivan.

We claim that the maximum possible sum is \( \frac{(n-1)n(n+1)}{6} \). We will prove this by induction.

1. **Base Case: \( n = 2 \)**
   - Let the two numbers be \( a_1 \) and \( a_2 \) with \( a_1 < a_2 \).
   - The only pairwise sum is \( a_1 + a_2 \).
   - Since \( a_1 < a_1 + a_2 \) and \( a_2 < a_1 + a_2 \), we need to check if \( a_1 \) or \( a_2 \) divides \( a_1 + a_2 \).
   - Clearly, \( a_1 \) divides \( a_1 + a_2 \) but \( a_2 \) does not divide \( a_1 + a_2 \) because \( a_2 \) is greater than \( a_1 \).
   - Therefore, the number written on the board is 1.
   - The sum of the numbers written by Ivan is \( 1 \), which matches \( \frac{(2-1)2(2+1)}{6} = 1 \).

2. **Inductive Step: Assume the statement is true for \( n \)**
   - Suppose the statement holds for \( n \) distinct positive integers.
   - Let the numbers be \( a_1 < a_2 < \cdots < a_{n+1} \).
   - By the inductive hypothesis, the sum of the numbers written on the board for the first \( n \) numbers is at most \( \frac{(n-1)n(n+1)}{6} \).

3. **Consider the quantities \( a_{n+1} + a_i \) for \( i = 1, 2, \ldots, n \)**
   - For each \( i \), \( a_i \) divides at most \( n+1-i \) of these quantities.
   - If \( a_i \) divides \( a_{n+1} + a_\ell \) and \( a_{n+1} + a_m \) for \( \ell, m \leq i \), then \( a_i \) also divides \( a_\ell - a_m \), which is a contradiction since \( a_\ell - a_m < a_i \).

4. **Sum of the numbers written for \( a_{n+1} + a_i \)**
   - For each \( a_{n+1} + a_i \), a number at most \( n+1-i \) is written on the board.
   - This increases the total by at most \( \sum_{i=1}^n (n+1-i) = \frac{n(n+1)}{2} \).

5. **Total sum calculation**
   - The total sum is at most:
     \[
     \frac{(n-1)n(n+1)}{6} + \frac{n(n+1)}{2}
     \]
   - Simplifying this, we get:
     \[
     \frac{(n-1)n(n+1)}{6} + \frac{3n(n+1)}{6} = \frac{(n-1)n(n+1) + 3n(n+1)}{6} = \frac{n(n+1)(n+2)}{6}
     \]

6. **Construction for equality**
   - Consider the numbers \( 2^1, 2^2, \ldots, 2^n \).
   - For \( i < j \), \( 2^k \) divides \( 2^i + 2^j \) only for \( k \leq i \).
   - This makes equality hold in the above proof.

Thus, the maximum possible sum of the numbers written by Ivan is \( \frac{(n-1)n(n+1)}{6} \).

The final answer is \( \boxed{\frac{(n-1)n(n+1)}{6}} \).