Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var fin,fout: text;
- a: array [1..10000] of longint;
- i,j,n:integer;
- b,d: longint;
- ofl,fl: boolean;
- begin
- assign(fin,'input.txt');
- assign(fout,'output.txt');
- reset(fin);
- rewrite(fout);
- read(fin,d);
- read(fin,n);
- ofl:=false;
- for i:=1 to (n - 2) do
- begin
- read(fin,a[i]);
- d:=d - a[i];
- end;
- for i:=1 to (d-1) do
- begin
- fl:=true;
- for j:=1 to (n-2) do
- if i=a[j] then fl:=false;
- if fl=true then
- begin
- b:=d-i;
- fl:=true;
- for j:=1 to (n-2) do
- if b=a[j] then fl:=false;
- if (b=i) then fl:=false;
- if fl=true then
- begin
- write(fout,i);
- ofl:=true;
- break;
- end;
- end;
- end;
- if ofl=false then
- write(fout,-1);
- close(fin);
- close(fout);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement