How much can we rearrange a series? There's a well-known result that if $\sum a_n$ is conditionally convergent, then for any real $c$ there exists a permutation $\pi:\mathbb{N} \to \mathbb{N}$ such that $\sum a_{\pi(n)} = c$.
A consequence of this is that you cannot get away with rearranging infinite sums, in general. However, if the rearrangement is sufficiently tame, then we can get away this. For instance, if we rearrange only finitely many terms, we can get away with this without the value of the sum changing. Indeed, there is a stronger result that if we have a permutation $\pi$ and a uniform constant $M$ such that $|\pi(n) - n| < M$ for all positive integers $n$, then $\sum a_n = \sum a_{\pi(n)}$. This is not too hard to prove. My question is, essentially, can we get a "maximally strong" result of this sort?
Specifically I ask the following question:

Characterize permutations $\pi:\mathbb{N} \to \mathbb{N}$ with the following property:
For any convergent infinite sum $\sum a_n$, we have that $\sum a_n = \sum a_{\pi(n)}$.

Notice the order of quantifiers here.
It's conceivable that the result I described in the second paragraph is the best we can do, in the sense that if $\sup_n |\pi(n) - n| = \infty$, there exists a conditionally convergent $a_n$ with $\sum a_n \neq \sum a_{\pi(n)}$. Perhaps we can do better, though. One guess is slightly changing the hypotheses as follows: there exists a uniform $M$ such that $|\pi(n) - n| < M$ for all $n \in \mathbb{N} \setminus S$, where $S$ is a subset of $\mathbb{N}$ with $0$ asymptotic density.
 A: A solution was pointed out by @fedja in the comment. I give here a complete proof. A necessary and sufficient condition on $\pi$ is :

$(C)$ There is a constant $M>0$ such that for every $n \in \mathbb N$, $\pi(\{0,\ldots , n\})$ is a union of at most $M$ intervals of consecutive integers

Proof
Let us write $[m,n] = \{m,m+1,\ldots ,n-1 \}$ for any integers $n\in\mathbb N$.

*

*Let $M>0$ be as in $(C)$. For $n$ big enough we can write :
$$\pi([0,n]) = [0,b^1_n] \cup [a^2_n,b^2_n] \cup \ldots \cup [a^M_n,b^M_n]$$
with $b_1^n < a^{2}_n \leq b^2_n <a^3_n\leq \ldots$ (since $[k,k] = \emptyset$ there is some ambiguity, but we can always find such sequences).
Then $\lim_{n\to \infty} b_n^1 = +\infty$ and therefore :
$$\begin{array}{rcl}
\displaystyle\sum_{k=1}^n a_{\pi(k)} &=& \displaystyle\sum_{k=0}^{b^1_n} a_k + \sum_{i=2}^M \sum_{k= a^i_n}^{b^i_n} a_{k} \\
&\displaystyle\overset{ n\to\infty}{\longrightarrow}&\displaystyle \sum_{k=0}^\infty a_k
\end{array}$$


*Assume that for every $M>0$ there is a $n\in\mathbb N$ such that $\pi([0,n])$ is a disjoint union of $>M$ (separated) intervals of consecutive integers. Let us build $(a_n) \in {\mathbb R}^{\mathbb N}$ such that $\sum_{n=0}^\infty a_n= 0$ and $\sum_n a_{\pi(n)}$ does not.

We can find a strictly increasing sequence of integers $N_k$ such that  :

*

*$\pi([0,N_k])$ is a disjoint union of $>k$ intervals of consecutive integers.

*the first interval of $\pi([0,N_{k+1}])$ contains $0$ and $\pi([0,N_k])$.

Then for $n\in\mathbb N$, let :
$$a_n = \left\{ \begin{array}{cl}
\frac{1}{k} & \text{if } n \text{ is the first integers of one of the intervals of } \pi([0,N_k]) \\
-\frac{1}{k} &\text{if } n+1 \text{ is the first integers of one of the intervals of } \pi([0,N_k]) \\
0 & \text{else}
\end{array}\right.$$
This way, we have :
\begin{align}
\lim_{N\to \infty} \sum_{n=0}^N a_n = 0 \\
\forall k\in \mathbb N, \sum_{n=0}^{N_k} a_{\pi(n)} \geq 1
\end{align}
Remarks and further questions
Another related question is to find permutations $\pi$ such that $\sum a_n$ and $\sum a_{\pi(n)}$ converge, their sum is the same. This is for example the case if $\pi([0,n]) = [0,n]$ infinitely often, which is compatible with $(\neg C)$.
