It is known that a polynomial $P$ with integer coefficients has degree $2022$. What is the maximum $n$ such that there exist integers $a_1, a_2, \cdots a_n$ with $P(a_i)=i$ for all $1\le i\le n$? 

[Extra: What happens if $P \in \mathbb{Q}[X]$ and $a_i\in \mathbb{Q}$ instead?]