There are $n$ players in a round-robin ping-pong tournament (i.e. every two persons will play exactly one game). After some matches have been played, it is known that the total number of matches that have been played among any $n-2$ people is equal to $3^k$ (where $k$ is a fixed integer). Find the sum of all possible values of $n$.
1. We start with the given information that the total number of matches played among any \( n-2 \) people is equal to \( 3^k \), where \( k \) is a fixed integer. The number of matches played among \( n-2 \) people can be represented by the binomial coefficient \( \binom{n-2}{2} \).

2. The binomial coefficient \( \binom{n-2}{2} \) is given by:
   \[
   \binom{n-2}{2} = \frac{(n-2)(n-3)}{2}
   \]
   According to the problem, this is equal to \( 3^k \):
   \[
   \frac{(n-2)(n-3)}{2} = 3^k
   \]
   Multiplying both sides by 2, we get:
   \[
   (n-2)(n-3) = 2 \cdot 3^k
   \]

3. We need to find the integer values of \( n \) such that \( (n-2)(n-3) = 2 \cdot 3^k \). Notice that \( (n-2) \) and \( (n-3) \) are consecutive integers, and their product is \( 2 \cdot 3^k \).

4. Since \( (n-2) \) and \( (n-3) \) are consecutive integers, one of them must be even, and the other must be odd. Therefore, one of them must be equal to 2 (the only even factor of \( 2 \cdot 3^k \)).

5. Let's consider the two cases:
   - Case 1: \( n-2 = 2 \)
     \[
     n-2 = 2 \implies n = 4
     \]
     Substituting \( n = 4 \) into the equation:
     \[
     (4-2)(4-3) = 2 \cdot 3^k \implies 2 \cdot 1 = 2 \cdot 3^k \implies 2 = 2 \cdot 3^k
     \]
     This implies \( 3^k = 1 \), which is not possible since \( 3^k \) is a power of 3 and cannot be 1.

   - Case 2: \( n-3 = 2 \)
     \[
     n-3 = 2 \implies n = 5
     \]
     Substituting \( n = 5 \) into the equation:
     \[
     (5-2)(5-3) = 2 \cdot 3^k \implies 3 \cdot 2 = 2 \cdot 3^k \implies 6 = 2 \cdot 3^k
     \]
     This implies \( 3^k = 3 \), so \( k = 1 \).

6. Therefore, the only possible value of \( n \) that satisfies the given condition is \( n = 5 \).

7. Summing all possible values of \( n \):
   \[
   \boxed{5}
   \]