Find the sum of all positive integers $n$ such that, given an unlimited supply of stamps of denominations $5,n,$ and $n+1$ cents, $91$ cents is the greatest postage that cannot be formed.
With $k$ stamps of value $n$ or $n+1$ we can make every amount in $[kn,kn+k]$; adding $5$'s, every larger amount in the same residue classes mod $5$. So the largest impossible amount is $f-5$, where $f$ is the largest of the first reachable values of the five residue classes.
Tracking residues of $kn,\dots,kn+k$: if $n\equiv1$ or $2\pmod5$, the last class appears at $2n+2$; if $n\equiv3$, at $2n+1$; if $n\equiv4$, at $4n$; if $n\equiv0$, at $4n+4$. So the largest impossible amount is $2n-3$, $2n-4$, $4n-5$, or $4n-1$ respectively.
$2n-3=91$ gives $n=47\equiv2$ (valid); $4n-5=91$ gives $n=24\equiv4$ (valid); the other two give no valid $n$.
The sum is $47+24=71$. The answer is $\boxed{071}$.
Find the sum of all positive integers $n$ such that, given an unlimited supply of stamps of denominations $6,n,$ and $n+1$ cents, $89$ cents is the greatest postage that cannot be formed.