program exetasi1( input, output) ;
var n, i, j, position, sum0, min : integer ;
a : array [ 1 .. 1000000 ] of integer ;
begin
readln ( n) ;
for i : = 1 to n do read ( a[ i] ) ;
if a[ 1 ] >0 then sum0 : = ( a[ 1 ] + a[ 2 ] )
else if a[ n] <0 then sum0 : = ( a[ n] + a[ n - 1 ] )
else
begin
sum0 : = 2 * 1000000000 ;
for i : = 1 to n do
begin
if a[ n] >0 then do position : = a[ n- 1 ] ;
end ;
for i : = 1 to position do
begin
for j : = ( position + 1 ) to ( n - 1 ) do
begin
if abs ( a[ j] ) <abs ( a[ i] ) and ( abs ( a[ j + 1 ] > abs ( a[ i] ) then
begin
if abs ( a[ i] + a[ j] ) < abs ( a[ i] + a[ j + 1 ] ) then min : = abs ( a[ i] + a[ j] )
else min : = abs ( a[ i] + a[ j + 1 ] )
end ;
if abs ( min) <abs ( sum0) then sum0 : = min
end
end
if position<= ( n - 2 ) then
begin
if ( a[ position + 1 ] + a[ position + 2 ] ) <abs ( sum0) then sum0 : = ( a[ position + 1 ] + a[ position + 2 ] )
end ;
if position >= 3 then
begin
if abs ( a[ position - 1 ] + a[ position] ) < abs ( sum0) then sum0 : = ( a[ position] + a[ position - 1 ] )
end
end ;
writeln ( sum0)
end .
cHJvZ3JhbSBleGV0YXNpMShpbnB1dCxvdXRwdXQpOwoJdmFyICBuLGksaixwb3NpdGlvbixzdW0wLG1pbiA6IGludGVnZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhIDogYXJyYXlbMS4uMTAwMDAwMF0gb2YgaW50ZWdlcjsKCmJlZ2luCiAgIHJlYWRsbihuKTsKICAgZm9yIGkgOj0gMSB0byBuIGRvIHJlYWQoYVtpXSk7CiAgIGlmIGFbMV0+MCB0aGVuIHN1bTAgOj0gKGFbMV0gKyBhWzJdKQogICBlbHNlIGlmIGFbbl08MCB0aGVuIHN1bTAgOj0gKCBhW25dICsgYVtuIC0gMV0pCiAgIGVsc2UKICAgYmVnaW4KICAgICAgc3VtMCA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aXRpb24gIC0gMV0pCiAgICAgICBlbmQKICBlbmQ7CiAgd3JpdGVsbihzdW0wKQplbmQuCiAgICAgICAgICAKICAgICAgIA==
compilation info
Free Pascal Compiler version 2.2.0 [2009/11/16] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Linux for i386
Compiling prog.pas
prog.pas(12,16) Warning: range check error while evaluating constants
prog.pas(15,24) Error: Illegal expression
prog.pas(15,27) Error: Illegal expression
prog.pas(15,27) Fatal: Syntax error, ";" expected but "identifier POSITION" found
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)
stdout