[guided]We now turn equality at almost all Frobenius elements into equality everywhere. The important point is that Chebotarev is a statement about a [Galois group](/page/Galois%20Group) unramified outside the chosen finite set, so we first pass to that quotient.
Let $\mathbb{Q}_S$ denote the maximal algebraic extension of $\mathbb{Q}$ unramified outside $S$, and let
\begin{align*}
\pi_S: G_{\mathbb{Q}}&\longrightarrow G_{\mathbb{Q},S}:=\operatorname{Gal}(\mathbb{Q}_S/\mathbb{Q})
\end{align*}
be the natural continuous quotient homomorphism. Its kernel is the closed normal subgroup generated by the inertia subgroups at rational primes $p\notin S$. Why is this the right quotient? Because a representation unramified outside $S$ is precisely insensitive to inertia at all primes outside $S$. Since each $\rho_i$ is unramified outside $S$, it is trivial on those inertia subgroups, and hence trivial on their closed normal closure. Therefore there are unique continuous representations
\begin{align*}
\bar{\rho}_i: G_{\mathbb{Q},S}&\longrightarrow GL_n(K)
\end{align*}
such that
\begin{align*}
\rho_i=\bar{\rho}_i\circ \pi_S
\end{align*}
for $i\in\{1,2\}$.
Define the descended trace functions
\begin{align*}
\bar{\chi}_i: G_{\mathbb{Q},S}&\longrightarrow K\\
\gamma&\longmapsto \operatorname{tr}\bar{\rho}_i(\gamma)
\end{align*}
for $i\in\{1,2\}$, and define their difference
\begin{align*}
\bar{\chi}: G_{\mathbb{Q},S}&\longrightarrow K\\
\gamma&\longmapsto \bar{\chi}_1(\gamma)-\bar{\chi}_2(\gamma).
\end{align*}
The maps $\bar{\rho}_i$ are continuous by construction from the quotient, and the trace map $GL_n(K)\to K$ is continuous in the $l$-adic topology. Hence $\bar{\chi}_1$, $\bar{\chi}_2$, and $\bar{\chi}$ are continuous.
For every $p\notin S$, the prime $p$ is unramified in $\mathbb{Q}_S/\mathbb{Q}$, so it has a Frobenius conjugacy class $\operatorname{Frob}_p$ in $G_{\mathbb{Q},S}$. The equality from the hypothesis, rewritten through the factorizations $\rho_i=\bar{\rho}_i\circ \pi_S$, gives
\begin{align*}
\bar{\chi}(\operatorname{Frob}_p)
=
\operatorname{tr}\bar{\rho}_1(\operatorname{Frob}_p)
-
\operatorname{tr}\bar{\rho}_2(\operatorname{Frob}_p)
=0.
\end{align*}
Trace is invariant under conjugation, so this value is independent of the chosen representative of the Frobenius conjugacy class.
We verify the class-function condition needed to use the density of conjugacy classes. For every $\gamma,\delta\in G_{\mathbb{Q},S}$ and each $i\in\{1,2\}$,
\begin{align*}
\bar{\chi}_i(\delta\gamma\delta^{-1})
&=\operatorname{tr}\bar{\rho}_i(\delta\gamma\delta^{-1})\\
&=\operatorname{tr}\bigl(\bar{\rho}_i(\delta)\bar{\rho}_i(\gamma)\bar{\rho}_i(\delta)^{-1}\bigr)\\
&=\operatorname{tr}\bar{\rho}_i(\gamma)\\
&=\bar{\chi}_i(\gamma),
\end{align*}
where the third equality is invariance of trace under conjugation in $GL_n(K)$. Thus $\bar{\chi}=\bar{\chi}_1-\bar{\chi}_2$ is a continuous class function on $G_{\mathbb{Q},S}$.
The density input is Chebotarev's density theorem for the maximal extension of $\mathbb{Q}$ unramified outside $S$ (citing a result not yet in the wiki: Chebotarev density theorem). In the precise form used here, it says that the union of Frobenius conjugacy classes $\operatorname{Frob}_p$ with $p\notin S$ is dense in the profinite group $G_{\mathbb{Q},S}$. Since $\bar{\chi}$ is continuous, vanishes on that dense union, and $\{0\}$ is closed in the Hausdorff topological field $K$, continuity forces
\begin{align*}
\bar{\chi}(\gamma)=0
\end{align*}
for every $\gamma\in G_{\mathbb{Q},S}$.
Finally we pull the equality back from the quotient to the original absolute Galois group. Define
\begin{align*}
\chi_i: G_{\mathbb{Q}}&\longrightarrow K\\
g&\longmapsto \operatorname{tr}\rho_i(g)
\end{align*}
for $i\in\{1,2\}$. For every $g\in G_{\mathbb{Q}}$,
\begin{align*}
\chi_1(g)-\chi_2(g)
&=\operatorname{tr}\bar{\rho}_1(\pi_S(g))-\operatorname{tr}\bar{\rho}_2(\pi_S(g))\\
&=\bar{\chi}(\pi_S(g))\\
&=0.
\end{align*}
Therefore
\begin{align*}
\operatorname{tr}\rho_1(g)=\operatorname{tr}\rho_2(g)
\end{align*}
for every $g\in G_{\mathbb{Q}}$.[/guided]