Question: Let's consider the following sequence:

$$9,8,7,6,5,4,3,2,1,0,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71...$$
This is the sequence of \$9\$'s complement of a number: that is, \$ a(x) = 10^d - 1 - x \$ where \$ d \$ is the number of digits in \$ x \$. ([A061601](https://oeis.org/A061601) in the OEIS).Your task is to add the first \$n\$ elements.

### Input

A number \$n∈[0,10000]\$.

### Output

The sum of the first \$n\$ elements of the sequence.

### Test cases

```
0 -> 0
1 -> 9
10 -> 45
100 -> 4050
1000 -> 408600
10000 -> 40904100

```

Standard [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") rules apply. The shortest code in bytes wins.

Answer: 
[R](https://www.r-project.org/), 37 bytes
=========================================

```r
f=function(n)sum(10^nchar(1:n-1)-1:n)

```

[Try it online!](https://tio.run/##K/r/P802rTQvuSQzP08jT7O4NFfD0CAuLzkjsUjD0CpP11BTF0hp/k/TMNTkAhIGEBJGwWkDzf8A "R – Try It Online")

**note**
I left out the check for 0 as I do not think it is part of the sequence as refered to A061601 in the OEIS reference. Adding the check would result in the exact same answer of Giuseppe, which would surely be preferable including the correct answer including 0.
[Julia 1.0](http://julialang.org/), ~~43~~ ~~38~~ 30 bytes
==========================================================

```julia
!n=n>0&&10^ndigits(~-n)-n+!~-n

```

[Try it online!](https://tio.run/##yyrNyUw0rPj/XzHPNs/OQE3N0CAuLyUzPbOkWKNON09TN09bEUj/L0ktLolPTixOLVawVYg20DHUMQQSBmAMIQxiuTT0FBHq9GxtgeosdUxMdUwMTA2AhIWZAYiyNDABqo/V1KuxKyjKzCvJyfsPAA "Julia 1.0 – Try It Online")

-5 dingledooper, -8 MarcMush