You have to play with the order of evaluation. Here is a way:
Clear[p];
p[n_, k_] := Apply[Sum,
  {IntegerPart[(2 + n -
       Sum[i  m[i], {i, 3, k}])/2],
   Sequence @@ Table[
     {m[k - l],
      IntegerPart[(k - l)/k],
      (n - Sum[(s)  m[s],
          {s, k - l + 1, k}])/(k - l)},
     {l, 0, k - 3}]}]