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: 
[Vyxal](https://github.com/Vyxal/Vyxal) `r`, 8 bytes
====================================================

No, I'm not Jo King. I found another use for the `r` flag!!!

> 
> It happens once in a blue moon on average
> 
> 
> 

Okay, yes, I said that

```
ʁƛL↵-‹;∑

```

[Try it Online!](https://vyxal.pythonanywhere.com/#WyJyIiwiIiwiyoHGm0zihrUt4oC5O+KIkSIsIiIsIjEwIl0=)
[Flagless 9 bytes](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLKgcabTOKGtW4t4oC5O+KIkSIsIiIsIjEwIl0=)

Explanation
-----------

So the `r` flag is basically a reverser, which reverses the order of the arguments. That makes it hard to use for long programs, but for short ones like this, it's useful sometimes.

```
ʁƛL↵-‹;∑
ʁ          create list with range(0, n)
 ƛ         open mapping lambda (with loop item n)
  L↵       push 10 to the length of n
    -      n - the latter (because it's reversed)
     ‹;    decrement by 1 and close lambda
       ∑   sum list

```
[Python 2](https://docs.python.org/2/), 42 bytes
================================================

```python
f=lambda n:n and-~~n+10**len(`n-1`)+f(n-1)

```

[Try it online!](https://tio.run/##FcVNCoAgFEbReat4Q38StGHQSiLQMEmoT5EmTdy62eXCye9zJkytheVy9@4dYQY5eFUrpNFCXAeYhTKWy8C6vIVUKFIErXok0//RepsH6uUS8bDAIuftAw "Python 2 – Try It Online")