5. Given a convex $n$-sided polygon where the degrees of the $n$ interior angles are all integers and distinct, and the largest interior angle is three times the smallest interior angle. Then the maximum value of $n$ is $\qquad$

 untranslated part: $\qquad$
5.20.

Let the interior angles in decreasing order be
$$
\begin{array}{l}
\theta_{1}>\theta_{2}>\cdots>\theta_{n} . \\
\text { Then } \sum_{k=1}^{n} \theta_{k}=180(n-2) .
\end{array}
$$

Since the $n$ interior angles are all integers,
$$
180>\theta_{1}=3 \theta_{n} \Rightarrow \theta_{1} \leqslant 177, \theta_{n} \leqslant 59 \text {. }
$$

Furthermore, since the $n$ interior angles are all distinct integers,
$$
\begin{array}{l}
\theta_{k} \leqslant 178-k(k=1,2, \cdots, n-1) . \\
\text { Therefore, } 180(n-2)=\sum_{k=1}^{n} \theta_{k} \\
\leqslant 59+\sum_{k=1}^{n-1}(178-k) \\
=59+178(n-1)-\frac{1}{2}(n-1) n \\
\Rightarrow n^{2}+3 n-482 \leqslant 0 \\
\Rightarrow n \leqslant \frac{-3+\sqrt{9+4 \times 482}}{2} .
\end{array}
$$

Given that $n$ is a positive integer, we have $n \leqslant 20$.
When $n=20$,
$$
\begin{array}{l}
59+\sum_{k=1}^{n-1}(178-k)=3251, \\
180(n-2)=3240,
\end{array}
$$

Thus, the $n$ interior angles with degrees $177,176, \cdots, 160$, 148,59 satisfy the conditions.
In conclusion, the maximum value of $n$ is 20.