As @Sil already has mentioned in a comment below your question, your problem is that you have a undetermined sum and product. For example assume you want to take derivative with respect to z2, how can Maple check if there is a z2 in your expression? L is not defined so it's not clear what indices exist in your expression. What you can do is as following. If you need the Q expression for different values of L, then define a function of L or a procedure with L as its input. So when you want to compute something related to Q of a specific L, you just put Q equal to the output of that procedure for your choice of L, then do the computations.
Qproc := proc(L)
local l;
return(p*A*product(z[l]^a[l],l=1..L-1)-add(w[l]*z[l],l=1..L-1);
end proc:
This procedure returns you your Q expression for a given choice of L. Let's say I want $L=3$. Then I do as following.
Q:=Qproc(3);
The Maple output will be;

Then you can ask derivatives with respect to z1 and z2, because now they are in your expression (not like when you had an undetermined sum and product!).
for l to 3 - 1 do
print(expand(z[l]*diff(Q,z[l])));
end do;
The Maple output is;
