There are $n$ stone piles each consisting of $2018$ stones. The weight of each stone is equal to one of the numbers $1, 2, 3, ...25$ and the total weights of any two piles are different. It is given that if we choose any two piles and remove the heaviest and lightest stones from each of these piles then the pile which has the heavier one becomes the lighter one. Determine the maximal possible value of $n$.
1. **Claim**: The maximum possible value of \( n \) is \( \boxed{12} \).

2. **Construction of Piles**: 
   - Let pile \( k \) include:
     - \( 1 \) stone weighing \( 2k \),
     - \( k + 2004 \) stones weighing \( 24 \),
     - \( 13 - k \) stones weighing \( 25 \),
     - for \( k = 1, 2, \ldots, 12 \).

3. **Verification of Pile Weights**:
   - The total weight of pile \( k \) is:
     \[
     S_k = 2k \cdot 1 + 24 \cdot (k + 2004) + 25 \cdot (13 - k)
     \]
     Simplifying this:
     \[
     S_k = 2k + 24k + 24 \cdot 2004 + 25 \cdot 13 - 25k
     \]
     \[
     S_k = 2k + 24k - 25k + 24 \cdot 2004 + 25 \cdot 13
     \]
     \[
     S_k = k + 24 \cdot 2004 + 325
     \]
     Since \( 24 \cdot 2004 + 325 \) is a constant, the total weight \( S_k \) is different for each \( k \).

4. **Proof that \( n < 13 \)**:
   - Let the initial total weights of the \( n \) piles be \( S_1 < S_2 < \ldots < S_n \).
   - After removing the heaviest and lightest stones, let the final total weights be \( S_1' > S_2' > \ldots > S_n' \).
   - Notice that:
     \[
     S_n - S_n' \geq (S_1 + n - 1) - (S_1' - (n - 1)) = S_1 - S_1' + 2(n - 1)
     \]
   - The heaviest stone removed from the lightest pile must be at least the mean of the remaining \( 2016 \) stones in the pile, and the lightest stone from that pile must weigh at least \( 1 \). So:
     \[
     S_1 - S_1' \geq \frac{S_1'}{2016} + 1
     \]
   - The lightest stone from the heaviest pile must be at most the mean of the remaining \( 2016 \) stones in the pile, and the heaviest stone from that pile must weigh at most \( 25 \). So:
     \[
     \frac{S_n'}{2016} + 25 \geq S_n - S_n' \geq S_1 - S_1' + 2(n - 1)
     \]
     and
     \[
     \frac{S_n' - S_1'}{2016} + 24 \geq 2(n - 1)
     \]
     Simplifying this:
     \[
     2n - 2 < 24 \Rightarrow n < 13
     \]