{Woburn Challenge VII}
{Program TROOPS}

var inf, outf: text;
    n, m: integer;
    A: array[1..30000] of integer;
    runsum, i, j, k, l, r: longint;
    target, hits: longint;

begin
     assign(inf, 'sequence.in');
     assign(outf, 'sequence.out');
     reset(inf);
     rewrite(outf);
     readln(inf, n);
     for i:=1 to n do read(inf, A[i]);
     read(inf, m);
     for i:=1 to m do begin
         read(inf, target);
         runsum:=0;
         hits:=0;
         r:=0;
         while (runsum<target) and (r<n) do
               begin inc(r); inc(runsum, A[r]) end;
         if runsum=target then inc(hits);
         for l:=2 to n do begin
             dec(runsum, A[l-1]);
             while (runsum<target) and (r<n) do
                   begin inc(r); inc(runsum, A[r]) end;
             if runsum=target then inc(hits);
         end;
         write(outf, hits, ' ');
     end;
     close(inf);
     close(outf);
end.



Downloader failed!
Response object
006~ASP 0159~Buffering Off~Buffering must be on.