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: 
[Behaviour](https://github.com/FabricioLince/BehaviourExolang), ~~36~~ 29 bytes
===============================================================================

```
f=&#(a*&10^#(""+a)-1-a;>&a+b)

```

My own recently made esolang, so bear with me.

ungolfed and commented

```
f=&
    #(                  // deal with 0 case, convert nil into 0
      a * &             // generate array for n nine complements
        10^#(""+a)-1-a; // nine complements logic
      >&a+b             // reduce array by adding its items
    )

```

Test with:

```
f:0
f:1
f:10

```
[Charcoal](https://github.com/somebody1234/Charcoal), 12 bytes
==============================================================

```
Ｉ↨¹ＥＮ⁻Ｉ×Ｌι9ι

```

[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwymxOFXDUEfBN7FAwzOvoLTErzQ3KbVIQxMolJlXWgxRFZKZm1qs4ZOal16SoZEJlFOyVNIEUpmaIGD9/7@hgYHBf92yHAA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:

```
    Ｎ           Input as a number
   Ｅ            Map over implicit range
          9     Literal string `9`
       ×        Repeated by
         ι      Current value
        Ｌ       Length (of string representation)
      Ｉ         Cast to integer
     ⁻          Subtract
           ι    Current value
 ↨¹             Take the sum
Ｉ               Cast to string
                Implicitly print

```

(`Sum()` won't work for an input of `0`.)