The Solitude of Prime Numbers Recently I read the novel &quot;The Solitude of Prime Numbers&quot; where the main characters are somewhat compared to twin prime numbers (&quot;always together, but never touching&quot;).

A twin prime is a prime number that is either \$\require{cancel}2\$ less or \$2\$ more than another prime number —for example, the twin prime pair \$(41, 43)\$. In other words, a twin prime is a prime that has a prime gap of two. Sometimes the term twin prime is used for a pair of twin primes; an alternative name for this is prime twin or prime pair. Wikipedia

Although I didn't like much the depressing novel, and since I have fallen into PPCG lately, that raised a question in my mind...
Task:
Given a positive integer number \$N &gt; 4\$, find the lonely prime numbers (AKA isolated prime numbers) between the closest couples of twin primes.
Please note that in this case with the term lonely prime numbers, I mean all the prime numbers that are not twin primes and between couples of twin primes. That's why \$N &gt; 4\$ because the first two couples of prime numbers are \$(3, 5)\$ and \$(5, 7)\$.
Example:

\$N = 90\$.
Find the first two couples of twin primes \$&lt; N\$ and \$&gt; N\$. They are: \$(71, 73)\$ and \$(101, 103)\$.
Find the lonely primes in the range \$&gt; 73\$ and \$&lt; 101\$.
They are: \$79, 83, 89, 97\$.

Special cases:
- If N is in between two twin prime numbers, find the closest couples of twin primes \$&gt; N+1\$ and \$&lt; N-1\$. Example: \$N=72\$, find the closest couples of twin primes \$&gt; 73\$ and \$&lt; 71\$ then exclude from the list \$71\$ and \$73\$ because they are not *lonely primes*. So for \$N = 72\$ the expected result is:  \$67, \cancel{71}, \cancel{73}, 79, 83, 89, 97\$
- If N belongs to a couple of twin primes, for example \$N = 73\$, the closest couples of twin primes are \$(71, 73)\$ and \$(101, 103)\$. If \$N = 71\$, the closest couples of twin primes are \$(59, 61)\$ and \$(71, 73)\$.
Test cases:
N = 70   &gt;  Lonely primes are:  67
N = 71   &gt;  Lonely primes are:  67
N = 72   &gt;  Lonely primes are:  67, 79, 83, 89, 97 (not the twins 71 and 73)
N = 73   &gt;  Lonely primes are:  79, 83, 89, 97 
N = 90   &gt;  Lonely primes are:  79, 83, 89, 97
N = 201  &gt;  Lonely primes are:  211, 223
N = 499  &gt;  Lonely primes are:  467, 479, 487, 491, 499, 503, 509

Rules:

Write a full program or function that will take the number N from standard input.
Output the list of lonely primes in a readable format as csv, list, array, etc.
Shortest code wins.
Please include (when possible) a testable online fiddle.
PowerShell v2+, 237 149 147 231 216 181 174 169 166 bytes

param($n)filter f($a){'1'*$a-match'^(?!(..+)\1+$)..'}for($i=$n;!((f $i)-and(f($i+2)))){$i++}for(){if(f(--$i)){if((f($i-2))-or(f($i+2))){if($i-lt$n-1){exit}}else{$i}}}


Takes input $n. Defines a new function f as the regex prime function (here returning a Boolean if the input is a prime or not).

The next part sets $i to be equal to $n, then loops upward until we find the bottom half of our twin prime pair upper bound. E.g., for input 90, this stops at $i=101.

Then, we loop from the upper bound downward. I know, it looks like an infinite loop, but it'll eventually end.

If the current number is a prime (f(--$i)), but its +/- 2 isn't a prime, we add $i to the pipeline. However, if its +/- 2 is a prime, we check whether we're lower than $n-1 (i.e., to account for the situation when it's inside a twin prime pair), at which point we exit. At program completion, the pipeline is printed to screen via implicit Write-Output.

NB - Due to the looping structure, prints the primes in descending order. OP has clarified that's OK.

Examples

Output here is space-separated, as that's the default stringification method for an array.

PS C:\Tools\Scripts\golfing&gt; 70,71,72,73,90,201,499,982|%{"$_ --&gt; "+(.\the-solitude-of-prime-numbers.ps1 $_)}
70 --&gt; 67
71 --&gt; 67
72 --&gt; 97 89 83 79 67
73 --&gt; 97 89 83 79
90 --&gt; 97 89 83 79
201 --&gt; 223 211
499 --&gt; 509 503 499 491 487 479 467
982 --&gt; 1013 1009 997 991 983 977 971 967 953 947 941 937 929 919 911 907 887