x0={1.2,3.4,4.5,6.7};
F[x_]:= Module[
{n=Length[x]},
Sum[
InnerArg= x[[i]]x[[i+1]]+Cos[x[[i-1]]-x[[i]]];
Sin[InnerArg],
{i,2,n-1}
]
]
DF[{x1_,x2_,x3_,x4_}]=D[
F[{x1,x2,x3,x4}],{{x1,x2,x3,x4}}];
DDF[{x1_,x2_,x3_,x4_}]=D[
DF[{x1,x2,x3,x4}],{{x1,x2,x3,x4}}];

Clear[G]
c=0;
G[x2_,x3_]:=Module[
{},
c++;
F[{1,x2,x3,1}]
]

Plot3D[
G[x2,x3],
{x2, 0, 3},
{x3, 0, 3}
]

c

c=0;
NMinimize[
Hold[G[x2,x3]],
{x2,x3}
]

c

F[x0]
DF[x0]
DDF[x0]