This is exercise 1.15 from Stichtenoth's Algebraic Function Fields and Codes:
Assume that the constant field $K$ is algebraically closed. Show that for every integer $d\geq g$, there exists a divisor $A\in\text{Div}(F)$ with $\deg(A) = d$ and $\ell(A) = \deg(A) + 1 − g$.
The case $g=0$ is easy.
For $g>0$, we only need to consider the case $d=g$ since if $g=\deg(A)-\ell(A)+1$ for $\deg(A)=g$, then $g=\deg(A+kP)-\ell(A+kP)+1$ for every $k\geq 1$, wher $P$ is any place. Since $\overline{K}=K$, there is some $P$ with degree $1$, so $\deg(A+kP)=g+k$ may assume any value $\geq g$.
I'm trying to see if $A=gP$ works. If it does, we must have $\ell(A)=g+1-g=1$. In particular, $\mathscr{L}(P)=\mathscr{L}(2P)=...=\mathscr{L}(gP)=K$, so that all the gaps of $P$ are exactly $1,2,...,g$.
[Here, "$k$ is a gap" means there is no $z\in F$ with $(z)_\infty=kP$].
This is in accordance with Weierstrass gap theorem, which says $P$ has exactly $g$ gaps $1=i_1<i_2<...<i_g\leq 2g-1$. But how can I prove $i_1=1,i_2=2,...,i_g=g$?
Note that every place of $K$ has degree one. Let $D$ be a divisor with $\deg(D)\ge g+1$, so that $\ell(D)\ge2$. For a non-zero element $x\in\mathscr L(D)$, there exists a place $P$ such that $v_P(x)=v_P(D)=0$, since there are infinitely many places. Then $x\notin\mathscr L(D-P)$, and thus $0<\ell(D)-\ell(D-P)$. Coupled with $\ell(D)-\ell(D-P)\le\deg(P)=1$ it gives $\ell(D)-\ell(D-P)=1$.
For a canonical divisor $W$ and a place $Q$, repeating the above process we obtain places $P_1,\dots,P_{g-1}$ and a divisor $A=W+Q-(P_1+\dots+P_{g-1})$ with $\deg(A)=g$. Then $$\ell(W+Q)=\deg(W+Q)+1-g,$$ and $$\ell(W+Q)-\ell(A)=\deg(W+Q)-\deg(A),$$ as desired.
(It seems that it still holds for $g-1$, since $\ell(A)=1$, and $\ell(A-P)=0$ for some place $P$. Correct me if something wrong.)