about summary refs log tree commit diff
path: root/others/volume1/081.pas
blob: 11dce4b3c7dd247ba7352b67e84e89a59f99fad7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var
  b: array[0..1000001] of boolean;
  n, a, i, max: int32;

begin
  for i := 0 to 1000001 do
    b[i] := false;
  readln(n);
  repeat
    dec(n);
    read(a);
    b[a] := true
  until n = 0;
  max := 1;
  while n < 1000000 do
    if b[n + 1] and not b[n] then
      for i := n + 1 to 1000001 do
        begin
          if not b[i] then
            begin
              if i - n > max then
                max := i - n;
              n := i;
              break
            end
        end
    else
      inc(n);
  writeln(max - 1)
end.