var n,i : integer; a, b, c,d : array [0 .. 5000] of integer; function min(a,b : integer) : integer; begin if a