Number of ways to arrange N things in R numbered row such that 2 special things are selected and are not in first or last of the row From $n$ amount of things, if we take $r$ things in which $2$ special things  have to be selected,  how many ways  can we arrange the things so that the two special things are not in the first or last of the rows?
I want to solve this problem by finding out the (total ways - ways to have the special things at first or last).
I found total ways to be
$$\frac{(n-2)!(2nr-r^2-r)}{(n-r)!}$$
But the problem becomes an algebraic mess from there.
I would be forever grateful if anyone provides a solution using the total ways - first or last formula.
Edit : I have found the total amount of ways to be $$\frac{r(r-1)(n-2)!}{(n-r)!}$$ This is because the $1$st special thing can be sorted into $r$ positions , the $2$nd special thing can be sorted into $(r-1)$ positions  and the other $(n-2)$ things can be sorted into $(r-2)$ positions.
Edit(2) : Guys I think I got it.  The total ways can be calculated by
$$\frac{r(r-1)(n-2)!}{(n-r)!}$$
Now we calculate the number of ways the special letters are at $1$st or last of the row (we name this process point two)
Now,  we consider the following cases
Case : $1$
If the $1$st special letter is at the 1st of the row,  the $2$nd special letter has $(r-1)$ places to be so in this case, the $(n-2)$ other things/letters have $(r-2)$ places to be in
So in this case , Number of ways = $$\frac{(r-1)(n-2)!}{(n-r)!}$$
Case: $2$
If the 1st special letter is at the last of the row it follow the same process as case 1 . So the number of ways = $$\frac{(r-1)(n-2)!}{(n-r)!}$$
Case: $3$
In this case , we consider the $2$nd special letter being in the first of the row . The process clearly remains the same as Case 1
So, Number of ways =  $$\frac{(r-1)(n-2)!}{(n-r)!}$$
Case: $4$
In this case we consider $2$nd special letter being in the last of the row . The process clearly remains the same as case 1
So, Number of ways = $$\frac{(r-1)(n-2)!}{(n-r)!}$$
Total number of ways(In these 4 cases) = Case 1 + Case 2 + Case 3 + Case 4
=$$\frac{4(r-1)(n-2)!}{(n-r)!}$$
Some of these cases overlap since when suppose $1$st special letter is at the first of the row , the $2$nd special letter can be at the last of the row . So in this scenario , Case 1 and Case 4 overlap . In order to get rid of this overlapping we consider the following cases
Case $5$
This is the case of the $1$st special letter being in the $1$st of the row and the $2$nd special letter being at the last of the row. Since these two are fixed we have $(n-2)$ other things which can go in $(r-2)$ places.
So number of ways = $$\frac{(n-2)!}{(n-r)!}$$
Case $6$
This is the case of the $2$nd special letter being in the $1$st of the row and the $1$st special letter being in the last of the row . This follows the process of case 5 .
So number of ways = $$\frac{(n-2)!}{(n-r)!}$$
Adding these two cases we get the total number of ways the cases can overlap  = $$\frac{2(n-2)!}{(n-r)!}$$
We subtract these two cases from the first 4 cases =
$$\frac{(4r-6)(n-2)!}{(n-r)!}$$
This is Point $2$ , So we subtract this from the total number of ways and get the result of =
$$\frac{(r-2)(r-3)(n-2)!}{(n-r)!}$$
This is what the question asked
 A: The posting's use of the fraction $~\displaystyle \frac{(n-2)!}{(n-r)!}~$ suggests that all $n$ items are to be considered distinct from each other, and that (therefore), the order that the items appear in the row is pertinent.
I am assuming that there are exactly $r$ positions in the row, where the $r$ items are to be placed.
My approach is to take the distribution in stages, using Inclusion-Exclusion to polish the answer.  See this article for an
introduction to Inclusion-Exclusion.
Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.

First, you have to select $(r-2)$ non-special items to accompany the $2$ special items.
This can be done in
$$\binom{n-2}{r-2} ~~\text{ways}. \tag1 $$
Assume that $(r-2)$ non-special items have been selected.
For any set $E$ with a finite number of elements, let $|E|$ denote the number of elements in the set $E$.
Let $S$ denote the set of all distributions of the $[(r-2) + 2]$ selected items, where the restriction on where the two special items are placed is ignored.
Let $S_1$ denote the subset of $S$, where the 1st special item occurs in either the first or last position.
Let $S_2$ denote the subset of $S$, where the 2nd special item occurs in either the first or last position.
Then, the desired computation, omitting the factor in (1) above, will be
$$|S| - |S_1 \cup S_2|.$$
By inclusion-Exclusion, this equals 
$|S| - |S_1| - |S_2| + |S_1 \cap S_2|.$
Then:

*

*$|S| = r!.$


*$|S_1| = 2 \times (r-1)!$. 
That is, the 1st special item can go in either the first position, or the last position.  Once the 1st special item is set, there are $(r-1)!$ ways of positioning the other $(r-1)$ items, which includes the 2nd special item.


*$|S_2| = 2 \times (r-1)!$. 
This follows by the same analysis as in the previous bullet point.


*$|S_1 \cap S_2| = 2! \times (r-2)!.$ 
Here, it is being assumed that both the 1st special item and the 2nd special item are in violation.  There are $(2!)$ ways of arranging these two special items in the first/last places on the row.  Then, there are $(r-2)!$ ways of placing the remaining $(r-2)$ items.

Putting all of this together with the initial factor in (1) above gives a final computation of
$$\binom{n-2}{r-2} \times \left\{ ~[r!] - [4 \times (r-1)!] + [2 \times (r-2)!] ~\right\} $$
$$= \binom{n-2}{r-2} \times [(r-2)!] \times \left\{ ~[r(r-1)] - [4 \times (r-1)] + [2] ~\right\} $$
$$= \frac{(n-2)!}{(n-r)!} \times [r^2 - 5r + 6].$$
This answer agrees with the final calculation in the posted question.
