
EXAMPLE

a(1) = a(2) = a(3) = a(4) = a(5) = 1 due to the permutations (0,1), (0,2,1), (0,3,2,1), (0,3,2,4,1), (0,3,2,4,5,1).
a(6) = 2 due to the permutations
(0,3,6,2,4,5,1) and (0,3,6,5,2,4,1).
a(7) = 4 due to the permutations
(0,3,6,2,4,5,7,1), (0,3,6,2,7,4,5,1),
(0,3,6,5,2,7,4,1), (0,3,6,5,7,4,2,1).
a(8) = 11 due to the permutations
(0,3,6,2,4,5,8,7,1), (0,3,6,2,7,8,4,5,1), (0,3,6,2,8,4,5,7,1),
(0,3,6,2,8,7,4,5,1), (0,3,6,5,2,7,8,4,1), (0,3,6,5,2,8,7,4,1),
(0,3,6,5,7,8,2,4,1), (0,3,6,5,7,8,4,2,1), (0,3,6,5,8,2,7,4,1),
(0,3,6,5,8,4,2,7,1), (0,3,6,5,8,7,4,2,1).
a(9) > 0 due to the permutation (0,3,6,9,2,4,5,8,7,1).
a(10) > 0 due to the permutation (0,3,6,9,2,4,5,10,8,7,1).


MATHEMATICA

(* A program to compute required permutations for n = 8. *)
f[i_, j_]:=f[i, j]=PrimeQ[4(i^2+j)1]
V[i_]:=V[i]=Part[Permutations[{2, 3, 4, 5, 6, 7, 8}], i]
m=0
Do[Do[If[f[If[j==0, 0, Part[V[i], j]], If[j<7, Part[V[i], j+1], 1]]==False, Goto[aa]], {j, 0, 7}];
m=m+1; Print[m, ":", " ", 0, " ", Part[V[i], 1], " ", Part[V[i], 2], " ", Part[V[i], 3], " ", Part[V[i], 4], " ", Part[V[i], 5], " ", Part[V[i], 6], " ", Part[V[i], 7], " ", 1]; Label[aa]; Continue, {i, 1, 7!}]
