Subfield: Number Theory


Question: Let $n \geq 2$ be an integer, and let $a_{1}, a_{2}, \ldots, a_{n}$ be positive integers. Show that there exist positive integers $b_{1}, b_{2}, \ldots, b_{n}$ satisfying the following three conditions:

1. $a_{i} \leq b_{i}$ for $i=1,2, \ldots, n$;
2. the remainders of $b_{1}, b_{2}, \ldots, b_{n}$ on division by $n$ are pairwise different; and
3. $b_{1}+\cdots+b_{n} \leq n\left(\frac{n-1}{2}+\left\lfloor\frac{a_{1}+\cdots+a_{n}}{n}\right\rfloor\right)$.

(Here, $\lfloor x\rfloor$ denotes the integer part of real number $x$, that is, the largest integer that does not exceed $x$.)

Solution:
We define the $b_{i}$ recursively by letting $b_{i}$ be the smallest integer such that $b_{i} \geq a_{i}$ and such that $b_{i}$ is not congruent to any of $b_{1}, \ldots, b_{i-1}$ modulo $n$. Then $b_{i}-a_{i} \leq i-1$, since of the $i$ consecutive integers $a_{i}, a_{i}+1, \ldots, a_{i}+i-1$, at most $i-1$ are congruent to one of $b_{1}, \ldots, b_{i-1}$ modulo $n$. Since all $b_{i}$ are distinct modulo $n$, we have $\sum_{i=1}^{n} b_{i} \equiv \sum_{i=1}^{n}(i-1)=\frac{1}{2} n(n-1)$ modulo $n$, so $n$ divides $\sum_{i=1}^{n} b_{i}-\frac{1}{2} n(n-1)$. Moreover, we have $\sum_{i=1}^{n} b_{i}-\sum_{i=1}^{n} a_{i} \leq \sum_{i=1}^{n}(i-1)=\frac{1}{2} n(n-1)$, hence $\sum_{i=1}^{n} b_{i}-\frac{1}{2} n(n-1) \leq \sum_{i=1}^{n}$. As the left hand side is divisible by $n$, we have

$$
\frac{1}{n}\left(\sum_{i=1}^{n} b_{i}-\frac{1}{2} n(n-1)\right) \leq\left[\frac{1}{n} \sum_{i=1}^{n} a_{i}\right]
$$

which we can rewrite as

$$
\sum_{i=1}^{n} b_{i} \leq n\left(\frac{n-1}{2}+\left[\frac{1}{n} \sum_{i=1}^{n} a_{i}\right]\right)
$$

as required.
Note that the problem is invariant under each of the following operations:

- adding a multiple of $n$ to some $a_{i}$ (and the corresponding $b_{i}$ );
- adding the same integer to all $a_{i}$ (and all $b_{i}$ );
- permuting the index set $1,2, \ldots, n$.

We may therefore remove the restriction that our $a_{i}$ and $b_{i}$ be positive.

For each congruence class $\bar{k}$ modulo $n(\bar{k}=\overline{0}, \ldots, \overline{n-1})$, let $h(k)$ be the number of $i$ such that $a_{i}$ belongs to $\bar{k}$. We will now show that the problem is solved if we can find a $t \in \mathbb{Z}$ such that

$$
\begin{aligned}
h(t) & \geq 1 \\
h(t)+h(t+1) & \geq 2 \\
h(t)+h(t+1)+h(t+2) & \geq 3
\end{aligned}
$$

Indeed, these inequalities guarantee the existence of elements $a_{i_{1}} \in \bar{t}, a_{i_{2}} \in \bar{t} \cup \overline{t+1}$, $a_{i_{3}} \in \bar{t} \cup \overline{t+1} \cup \overline{t+2}$, et cetera, where all $i_{k}$ are different. Subtracting appropriate multiples of $n$ and reordering our elements, we may assume $a_{1}=t, a_{2} \in\{t, t+1\}$, $a_{3} \in\{t, t+1, t+2\}$, et cetera. Finally subtracting $t$ from the complete sequence, we may assume $a_{1}=0, a_{2} \in\{0,1\}, a_{3} \in\{0,1,2\}$ et cetera. Now simply setting $b_{i}=i-1$ for all $i$ suffices, since $a_{i} \leq b_{i}$ for all $i$, the $b_{i}$ are all different modulo $n$, and

$$
\sum_{i=1}^{n} b_{i}=\frac{n(n-1)}{2} \leq \frac{n(n-1)}{2}+n\left[\frac{\sum_{i=1}^{n} a_{i}}{n}\right]
$$

Put $x_{i}=h(i)-1$ for all $i=0, \ldots, n-1$. Note that $x_{i} \geq-1$, because $h(i) \geq 0$. If we have $x_{i} \geq 0$ for all $i=0, \ldots, n-1$, then taking $t=0$ completes the proof. Otherwise, we can pick some index $j$ such that $x_{j}=-1$. Let $y_{i}=x_{i}$ where $i=0, \ldots, j-1, j+1, \ldots, n-1$ and $y_{j}=0$. For sequence $\left\{y_{i}\right\}$ we have

$$
\sum_{i=0}^{n-1} y_{i}=\sum_{i=0}^{n-1} x_{i}+1=\sum_{i=0}^{n-1} h(i)-n+1=1
$$

so from Raney's lemma there exists index $k$ such that $\sum_{i=k}^{k+j} y_{i}>0$ for all $j=0, \ldots, n-1$ where $y_{n+j}=y_{j}$ for $j=0, \ldots, k-1$. Taking $t=k$ we will have

$$
\sum_{t=k}^{k+i} h(t)-(i+1)=\sum_{t=k}^{k+i} x(t) \geq \sum_{t=k}^{k+i} y(t)-1 \geq 0
$$

for all $i=0, \ldots, n-1$ and we are done.
Choose a random permutation $c_{1}, \ldots, c_{n}$ of the integers $1,2, \ldots, n$. Let $b_{i}=a_{i}+f\left(c_{i}-a_{i}\right)$, where $f(x) \in\{0, \ldots, n-1\}$ denotes a remainder of $x$ modulo $n$. Observe, that for such defined sequence the first two conditions hold. The expected value of $B:=b_{1}+\ldots+b_{n}$ is easily seen to be equal to $a_{1}+\ldots+a_{n}+n(n-1) / 2$. Indeed, for each $i$ the random number $c_{i}-a_{i}$ has uniform distribution modulo $n$, thus the expected value of $f\left(c_{i}-a_{i}\right)$ is $(0+\ldots+(n-1)) / n=(n-1) / 2$. Therefore we may find such $c$ that $B \leq a_{1}+\ldots+a_{n}+n(n-1) / 2$. But $B-n(n-1) / 2$ is divisible by $n$ and therefore $B \leq n\left[\left(a_{1}+\ldots+a_{n}\right) / n\right]+n(n-1) / 2$ as needed.
We will prove the required statement for all sequences of non-negative integers $a_{i}$ by induction on $n$.

Case $n=1$ is obvious, just set $b_{1}=a_{1}$.

Now suppose that the statement is true for some $n \geq 1$; we shall prove it for $n+1$.

First note that, by subtracting a multiple of $n+1$ to each $a_{i}$ and possibly rearranging indices we can reduce the problem to the case where $0 \leq a_{1} \leq a_{2} \leq \cdots \leq a_{n} \leq a_{n+1}<$ $n+1$.

Now, by the induction hypothesis there exists a sequence $d_{1}, d_{2}, \ldots, d_{n}$ which satisfies the properties required by the statement in relation to the numbers $a_{1}, \ldots, a_{n}$. Set $I=\{i \mid 1 \leq$ $i \leq n$ and $\left.d_{i} \bmod n \geq a_{i}\right\}$ and construct $b_{i}$, for $i=1, \ldots, n+1$, as follows:

$$
b_{i}=\left\{\begin{array}{l}
d_{i} \bmod n, \text { when } i \in I, \\
n+1+\left(d_{i} \bmod n\right), \text { when } i \in\{1, \ldots, n\} \backslash I, \\
n, \text { for } i=n+1
\end{array}\right.
$$



Now, $a_{i} \leq d_{i} \bmod n \leq b_{i}$ for $i \in I$, while for $i \notin I$ we have $a_{i} \leq n \leq b_{i}$. Thus the sequence $\left(b_{i}\right)_{i=1}^{n+1}$ satisfies the first condition from the problem statement.

By the induction hypothesis, the numbers $d_{i} \bmod n$ are distinct for $i \in\{1, \ldots, n\}$, so the values $b_{i} \bmod (n+1)$ are distinct elements of $\{0, \ldots, n-1\}$ for $i \in\{1, \ldots, n\}$. Since $b_{n+1}=n$, the second condition is also satisfied.

Denote $k=|I|$. We have

$$
\begin{gathered}
\sum_{i=1}^{n+1} b_{i}=\sum_{i=1}^{n} b_{i}+n=\sum_{i=1}^{n} d_{i} \bmod n+(n-k)(n+1)+n= \\
\frac{n(n+1)}{2}+(n-k)(n+1)
\end{gathered}
$$

hence we need to show that

$$
\frac{n(n+1)}{2}+(n-k)(n+1) \leq \frac{n(n+1)}{2}+(n+1)\left[\frac{\sum_{i=1}^{n+1} a_{i}}{n+1}\right]
$$

equivalently, that

$$
n-k \leq\left[\frac{\sum_{i=1}^{n+1} a_{i}}{n+1}\right]
$$

Next, from the induction hypothesis we have

$$
\begin{gathered}
\frac{n(n-1)}{2}+n\left[\frac{\sum_{i=1}^{n} a_{i}}{n}\right] \geq \sum_{i=1}^{n} d_{i}=\sum_{i \in I} d_{i}+\sum_{i \notin I} d_{i} \geq \\
\sum_{i \in I} d_{i} \bmod n+\sum_{i \notin I}\left(n+d_{i} \bmod n\right)=\frac{n(n-1)}{2}+(n-k) n
\end{gathered}
$$

or

$$
n-k \leq\left[\frac{\sum_{i=1}^{n} a_{i}}{n}\right]
$$

Thus, it's enough to show that

$$
\frac{\sum_{i=1}^{n} a_{i}}{n} \leq \frac{\sum_{i=1}^{n+1} a_{i}}{n+1}
$$

because then

$$
n-k \leq\left[\frac{\sum_{i=1}^{n} a_{i}}{n}\right] \leq\left[\frac{\sum_{i=1}^{n+1} a_{i}}{n+1}\right]
$$

But the required inequality is equivalent to $\sum_{i=1}^{n} a_{i} \leq n a_{n+1}$, which is obvious.
We can assume that all $a_{i} \in\{0,1, \ldots, n-1\}$, as we can deduct $n$ from both $a_{i}$ and $b_{i}$ for arbitrary $i$ without violating any of the three conditions from the problem statement. We shall also assume that $a_{1} \leq \ldots \leq a_{n}$.

Now let us provide an algorithm for constructing $b_{1}, \ldots, b_{n}$.



We start at step 1 by choosing $f(1)$ to be the maximum $i$ in $\{1, \ldots, n\}$ such that $a_{i} \leq n-1$, that is $f(1)=n$. We set $b_{f(1)}=n-1$.

Having performed steps 1 through $j$, at step $j+1$ we set $f(j+1)$ to be the maximum $i$ in $\{1, \ldots, n\} \backslash\{f(1), \ldots, f(j)\}$ such that $a_{i} \leq n-j-1$, if such an index exists. If it does, we set $b_{f(j+1)}=n-j-1$. If there is no such index, then we define $T=j$ and assign to the terms $b_{i}$, where $i \notin f(\{1, \ldots, j\})$, the values $n, n+1 \ldots, 2 n-j-1$, in any order, thus concluding the run of our algorithm.

Notice that the sequence $\left(b_{i}\right)_{i=1}^{n}$ satisfies the first and second required conditions by construction. We wish to show that it also satisfies the third.

Notice that, since the values chosen for the $b_{i}$ 's are those from $n-T$ to $2 n-T-1$, we have

$$
\sum_{i=1}^{n} b_{i}=\frac{n(n-1)}{2}+(n-T) n
$$

It therefore suffices to show that

$$
\left[\frac{a_{1}+\ldots+a_{n}}{n}\right] \geq n-T
$$

or (since the RHS is obviously an integer) $a_{1}+\ldots+a_{n} \geq(n-T) n$.

First, we show that there exists $1 \leq i \leq T$ such that $n-i=b_{f(i)}=a_{f(i)}$.

Indeed, this is true if $a_{n}=n-1$, so we may suppose $a_{n}<n-1$ and therefore $a_{n-1} \leq n-2$, so that $T \geq 2$. If $a_{n-1}=n-2$, we are done. If not, then $a_{n-1}<n-2$ and therefore $a_{n-2} \leq n-3$ and $T \geq 3$. Inductively, we actually obtain $T=n$ and necessarily $f(n)=1$ and $a_{1}=b_{1}=0$, which gives the desired result.

Now let $t$ be the largest such index $i$. We know that $n-t=b_{f(t)}=a_{f(t)}$ and therefore $a_{1} \leq \ldots \leq a_{f(t)} \leq n-t$. If we have $a_{1}=\ldots=a_{f(t)}=n-t$, then $T=t$ and we have $a_{i} \geq n-T$ for all $i$, hence $\sum_{i} a_{i} \geq n(n-T)$. Otherwise, $T>t$ and in fact one can show $T=t+f(t+1)$ by proceeding inductively and using the fact that $t$ is the last time for which $a_{f(t)}=b_{f(t)}$.

Now we get that, since $a_{f(t+1)+1} \geq n-t$, then $\sum_{i} a_{i} \geq(n-t)(n-f(t+1))=(n-T+f(t+$ 1)) $(n-f(t+1))=n(n-T)+n f(t+1)-f(t+1)(n-T+f(t+1))=n(n-T)+t f(t+1) \geq$ $n(n-T)$.