There are $n$ people, and given that any $2$ of them have contacted with each other at most once. In any group of $n-2$ of them, any one person of the group has contacted with other people in this group for $3^k$ times, where $k$ is a non-negative integer. Determine all the possible value of $n.$
1. **Understanding the problem**: We are given \( n \) people, and any two of them have contacted each other at most once. In any group of \( n-2 \) people, each person in the group has contacted the others exactly \( 3^k \) times, where \( k \) is a non-negative integer. We need to determine all possible values of \( n \).

2. **Initial conditions**: Since \( k \) is a non-negative integer, the smallest value \( 3^k \) can take is 1 (when \( k = 0 \)). This implies that \( n \geq 4 \) because if \( n < 4 \), the condition \( 3^k \) cannot be satisfied.

3. **Case \( n = 4 \)**: If \( n = 4 \), we can easily verify that \( k = 0 \) works. In this case, each person in any group of \( 2 \) people has contacted the other exactly once, which is \( 3^0 = 1 \). Therefore, \( n = 4 \) is a valid solution.

4. **General case \( n \geq 5 \)**: We need to consider the general case where \( n \geq 5 \) and \( k \geq 1 \). We represent the \( n \) people as points \( A_1, A_2, \ldots, A_n \). If \( A_i \) has contacted \( A_j \), we add an edge between these two points.

5. **Existence of edges**: There must be at least one edge in the graph. Without loss of generality, assume there is an edge between \( A_1 \) and \( A_2 \).

6. **Considering groups of \( n-2 \) people**: If there is no edge between \( A_1 \) and \( A_3 \), consider the groups \( \{A_1, A_4, A_5, \ldots, A_n\} \), \( \{A_2, A_4, A_5, \ldots, A_n\} \), and \( \{A_3, A_4, A_5, \ldots, A_n\} \). By the problem's conditions, \( A_1, A_2, \) and \( A_3 \) must have the same number of edges with \( A_4, A_5, \ldots, A_n \), denoted as \( m \).

7. **Calculating total edges**: Adding \( A_2 \) to the group \( \{A_1, A_4, A_5, \ldots, A_n\} \), the total number of edges in the \( n-1 \) points is \( S = 3^k + m + 1 \). Removing any point from the \( n-1 \) points, the remaining \( n-2 \) points have \( 3^k \) edges, so each point has \( m + 1 \) edges with the other \( n-2 \) points. Thus, \( S = \frac{1}{2} (n-1)(m+1) \).

8. **Consistency check**: Similarly, adding \( A_3 \) to the group \( \{A_1, A_4, A_5, \ldots, A_n\} \), the total number of edges in the \( n-1 \) points is \( t = 3^k + m = \frac{1}{2} (n-1)m \). Therefore, \( S = t + 1 \), leading to the equation:
   \[
   \frac{1}{2}(n-1)(m+1) = \frac{1}{2}(n-1)m + 1
   \]
   Simplifying this, we get:
   \[
   (n-1)(m+1) = (n-1)m + 2 \implies n-1 = 2 \implies n = 3
   \]
   This leads to a contradiction since \( n \geq 5 \).

9. **Existence of edges between all pairs**: Therefore, there must be an edge between \( A_1 \) and \( A_3 \). By similar reasoning, there must be an edge between any pair \( (A_i, A_j) \) for \( i \neq j \).

10. **Final equation**: The total number of edges in a complete graph of \( n-2 \) vertices is:
    \[
    3^k = \frac{1}{2}(n-2)(n-3)
    \]
    Solving for \( n \), we get:
    \[
    3^k = \frac{1}{2}(n-2)(n-3)
    \]
    For \( k = 1 \):
    \[
    3 = \frac{1}{2}(n-2)(n-3) \implies 6 = (n-2)(n-3) \implies n^2 - 5n + 6 = 0 \implies (n-2)(n-3) = 0
    \]
    Thus, \( n = 2 \) or \( n = 3 \), which is not possible since \( n \geq 5 \).

    For \( k = 2 \):
    \[
    9 = \frac{1}{2}(n-2)(n-3) \implies 18 = (n-2)(n-3) \implies n^2 - 5n + 6 = 0 \implies (n-2)(n-3) = 0
    \]
    Thus, \( n = 5 \).

The final answer is \( \boxed{ n = 5 } \).