{nolasa matricas datus(viena rinda vienas
matricas rindas skaitli)

aprekina rindu summas}

uses crt;
var f1,f2,f3: text;
    s1,s2,s3: string;
    i,s,x: integer;

    function get_num(var f: text): integer;
    var x :integer; ch: char;
    begin
     get_num:=-1;
     if not seekeof(f) then begin
       ch:=#0; x:=0;
       while not (ch in ['0'..'9']) do read(f,ch);
       while (ch in ['0'..'9']) do begin
         x:=x*10+(Ord(ch)-Ord('0'));
         read(f, ch);
       end;
       get_num:=x
     end;
    end;

begin
clrscr;
writeln('Imya pervogo fajla'); readln(s1);
writeln('Imya novogo fajla'); readln(s2);
assign(f1,s1); assign(f2,s2);
reset(f1); rewrite(f2);
while not eof(f1)
      do begin s:=0; x:=0;
      while (not eoln(f1)) and (x>-1)
            do begin x:=get_num(f1);
              if x<>-1 then s:=s+x;
            end;
      readln(f1);
      writeln(f2,s);
      end;
close(f1); close(f2);
readkey
end.