fork(1) download
  1. program ideone;
  2. var a, mx1, mx2:integer;
  3. begin
  4. read(a);
  5. mx1 := -32767;
  6. mx2 := -32767;
  7. while a <> 0 do
  8. begin
  9. if mx1 < a then
  10. begin
  11. mx2 := mx1;
  12. mx1 := a;
  13. end
  14. else if mx2 < a then
  15. mx2 := a;
  16. read(a);
  17. end;
  18.  
  19. write(mx1 + mx2);
  20. end.
Success #stdin #stdout 0s 5324KB
stdin
8
26
12
-10
47
25
-100
22
10
0
stdout
73