open Scanf open Array
let (++) = Int64.add
let () = scanf " %d %d %d" @@ fun n k x ->
  let a = init n (fun _ -> scanf " %Ld" @@ fun v -> v) in
  let undef = -1L in
  let dp = init (n+1) (fun _ -> make_matrix (x+1) (k+1) undef) in
  dp.(0).(x-1).(k) <- a.(0);
  dp.(0).(x).(k-1) <- 0L;
  let upd i j p v =
    dp.(i).(j).(p) <- max dp.(i).(j).(p) v
  in
  for i=0 to n-2 do
    for j=1 to x do
      for p=1 to k do
        if dp.(i).(j).(p) <> undef then (
          upd (i+1) (j-1) k @@
            dp.(i).(j).(p) ++ a.(i+1);
          upd (i+1) j (p-1) @@
            dp.(i).(j).(p))
      done
    done
  done;
  let mx = ref @@ -1L in
  for i=n-k to n do
    for p=0 to k do
      mx := max !mx dp.(i).(0).(p)
    done
  done;
  Printf.printf "%Ld\n" !mx

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n,k,x = get_3_i64 0 in
  let a = input_i64_array n in
  let undef = -7L in
  let dp = make_matrix (i32 n+$1) (i32 x+$1) @@ undef in
  let update i j v =
    try
      dp.(i).(j) <- max (dp.(i).(j)) v
    with Invalid_argument _ -> ()
  in
  repi 0 (i32 k-$1) (fun k ->
    dp.(k).(i32 x) <- 0L
  );
  repi 0 (i32 n-$1) (fun i ->
    repi 1 (i32 x) (fun j ->
      if dp.(i).(j) <> undef then
      repi 1 (i32 k) (fun k ->
        update (i+$k) (j-$1) @@ dp.(i).(j) + a.(i)
      )
    )
  );
  (* dump_2darr (sprintf "%4Ld") dp; *)
  (* let res = ref undef in
  repi 0 (i32 k-$1) (fun k ->
    res := max !res dp.(i32 n-$k).(0)
  );
  if dp.(i32 n).(0) = undef then res := undef;
  if !res = undef then printf "-1\n"
  else printf "%Ld\n" !res *)
  printf "%Ld\n" @@ let res = dp.(i32 n).(0) in if res = undef then -1L else res

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n,k,x = get_3_i64 0 in
  let a = input_i64_array n in
  let undef = -7L in
  let n,k,x = i32 n,i32 k,i32 x in
  let dp = make_matrix (n+$1) (x+$1) @@ undef in
  dp.(0).(x) <- 0L;
  repi 1 n (fun i ->
    repi 0 (x-$1) (fun j ->
      repi 1 k (fun k ->
        try
        let v = dp.(i-$k).(j+$1) in
        if v <> undef then
          dp.(i).(j) <- max dp.(i).(j) (v+a.(i-$1))
        with Invalid_argument _ -> ()
      )
    )
  );
  (* dump_2darr (sprintf "%3Ld") dp; *)
  let res = ref undef in
  repi (n-$k+$1) n (fun i ->
    res := max !res @@ dp.(i).(0)
  );
  printf "%Ld\n" @@ let v = !res in if v = undef then -1L else v

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n,k,x = get_3_i64 0 in
  let a = input_i64_array n in
  let undef = -7L in
  let dp = make_matrix (i32 n+$1) (i32 x+$1) @@ undef in
  let update i j v =
    try
      dp.(i).(j) <- max (dp.(i).(j)) v
    with Invalid_argument _ -> ()
  in
  repi 0 (i32 k-$1) (fun k ->
    dp.(k).(i32 x) <- 0L
  );
  repi 0 (i32 n-$1) (fun i ->
    repi_rev (i32 x) 1 (fun j ->
      repi 1 (i32 k) (fun k ->
        if dp.(i).(j) <> undef then
          update (i+$k) (j-$1) @@ dp.(i).(j) + a.(i)
      )
    )
  );
  (* dump_2darr (sprintf "%3Ld") dp; *)
  let res = ref undef in
  repi 0 (i32 k-$1) (fun k ->
    res := max !res dp.(i32 n-$k).(0)
  );
  if !res = undef then printf "-1\n"
  else printf "%Ld\n" !res

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n,k,x = get_3_i64 0 in
  let a = input_i64_array n in
  let undef = -7L in
  let dp = make_matrix (i32 n+$1) (i32 x+$1) @@ undef in
  let update i j v =
    try
      dp.(i).(j) <- max (dp.(i).(j)) v
    with Invalid_argument _ -> ()
  in
  repi 0 (i32 k-$1) (fun k ->
    dp.(k).(i32 x) <- 0L
  );
  repi 0 (i32 n-$1) (fun i ->
    repi 1 (i32 x) (fun j ->
      if dp.(i).(j) <> undef then
      repi 1 (i32 k) (fun k ->
        update (i+$k) (j-$1) @@ dp.(i).(j) + a.(i)
      )
    )
  );
  (* dump_2darr (sprintf "%10Ld") dp; *)
  let res = ref undef in
  repi 0 (i32 k-$1) (fun k ->
    res := max !res dp.(i32 n-$k).(0)
  );
  if dp.(i32 n).(0) = undef then res := undef;
  if !res = undef then printf "-1\n"
  else printf "%Ld\n" !res

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n,k,x = get_3_i64 0 in
  let a = input_i64_array n in
  let undef = -7L in
  let n,k,x = i32 n,i32 k,i32 x in
  let dp = make_matrix (n+$1) (x+$1) @@ undef in
  repi 0 (k-$1) (fun i ->
    dp.(i).(x) <- 0L
  );
  repi 1 n (fun i ->
    repi 0 (x-$1) (fun j ->
      repi 1 k (fun k ->
        try
        let v = dp.(i-$k).(j+$1) in
        if v <> undef then
          dp.(i).(j) <- max dp.(i).(j) (v+a.(i-$1))
        with Invalid_argument _ -> ()
      )
    )
  );
  (* dump_2darr (sprintf "%3Ld") dp; *)
  let res = ref undef in
  repi (n-$k+$1) n (fun i ->
    res := max !res @@ dp.(i).(0)
  );
  printf "%Ld\n" @@ let v = !res in if v = undef then -1L else v

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n,k,x = get_3_i64 0 in
  let a = input_i64_array n in
  let undef = -7L in
  let dp = make_matrix (i32 n+$1) (i32 x+$1) @@ undef in
  let update i j v =
    try
      dp.(i).(j) <- max (dp.(i).(j)) v
    with Invalid_argument _ -> ()
  in
  repi 0 (i32 k-$1) (fun k ->
    dp.(k).(i32 x) <- 0L
  );
  repi 0 (i32 n-$1) (fun i ->
    repi 1 (i32 x) (fun j ->
      if dp.(i).(j) <> undef then
      repi 1 (i32 k) (fun k ->
        update (i+$k) (j-$1) @@ dp.(i).(j) + a.(i)
      )
    )
  );
  (* dump_2darr (sprintf "%10Ld") dp; *)
  let res = ref undef in
  repib 0 (i32 k-$1) (fun k ->
    let v = dp.(i32 n-$k).(0) in
    if v = undef then (res := undef; `Break)
    else (res := max !res dp.(i32 n-$k).(0); `Ok)
  );
  if !res = undef then printf "-1\n"
  else printf "%Ld\n" !res

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module I64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n,k,x = get_3_i64 0 in
  let a = input_i64_array n in
  let undef = -7L in
  let dp = make_matrix (i32 n+$1) (i32 x+$1) @@ undef in
  let update i j v =
    try
      dp.(i).(j) <- max (dp.(i).(j)) v
    with Invalid_argument _ -> ()
  in
  repi 0 (i32 k-$1) (fun k ->
    dp.(k).(i32 x) <- 0L
  );
  repi 0 (i32 n-$1) (fun i ->
    repi 1 (i32 x) (fun j ->
      if dp.(i).(j) <> undef then
      repi 1 (i32 k) (fun k ->
        update (i+$k) (j-$1) @@ dp.(i).(j) + a.(i)
      )
    )
  );
  dump_2darr (sprintf "%10Ld") dp;
  let res = ref undef in
  repi 0 (i32 k-$1) (fun k ->
    res := max !res dp.(i32 n-$k).(0)
  );
  if dp.(i32 n).(0) = undef then res := undef;
  if !res = undef then printf "-1\n"
  else printf "%Ld\n" !res


let n = int_of_string (input_line stdin) ;;

let a = Array.make n 0 ;;

let rec aux i =
    Scanf.scanf "%d " (fun v -> Array.set a i v); aux (i + 1)
in try aux 0 with _ -> () ;;

Array.sort compare a ;;

Printf.printf "%d\n" (Array.get a ((n - 1) / 2)) ;;

open Printf
open Scanf

let read_int _ = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let a = Array.init n read_int in

  Array.sort compare a;

  let k = (n-1)/2 in

  printf "%d\n" a.(k)

open Printf
open Scanf

let read_int _ = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let a = Array.init n read_int in

  Array.sort compare a;

  let k = n/2 in

  printf "%d\n" a.(k)


(* Beautiful Mirrors
 * https://codeforces.com/problemset/problem/1265/E *)

open Printf
open Scanf

let ( ++ ) = Int64.add
let ( -- ) = Int64.sub
let ( ** ) = Int64.mul
let ( // ) = Int64.div

let ( %% ) a b = a -- (b ** (a//b))

let md = 998244353L

let ( *% ) a b = (a ** b) %% md

let pw a b =
  let a = a %% md in
  let rec iter acc a b =
    if b = 0L then
      acc
    else
      let a' = (a *% a) in
      let b' = b // 2L in
      if Int64.logand b 1L = 1L then
        iter (acc *% a)  a' b'
      else
        iter acc a' b' in
  iter 1L a b

let inv a = pw a (md -- 2L)

let () =
  let _ = read_int () in
  let i100 = inv 100L in
  let pl = read_line ()
           |> Str.split (Str.regexp " ")
           |> List.map Int64.of_string
           |> List.map (fun p -> p *% i100) in
  let (a, b) = List.fold_right
      (fun p (a, b) -> (p *% a ++ 1L, p *% (b -- 1L) ++ 1L))
      pl (0L, 0L) in
  printf "%Ld\n" (a *% (inv (md ++ 1L -- b)))

(* Beautiful Mirrors
 * https://codeforces.com/problemset/problem/1265/E *)

open Printf
open Scanf

let ( ++ ) = Int64.add
let ( -- ) = Int64.sub
let ( ** ) = Int64.mul
let ( // ) = Int64.div

let ( %% ) a b = a -- (b ** (a//b))

let md = 998244353L

let ( *% ) a b = (a ** b) %% md

let pw a b =
  let a = a %% md in
  let rec iter acc a b =
    if b = 0L then
      acc
    else
      let a' = (a *% a) in
      let b' = b // 2L in
      if Int64.logand b 1L = 1L then
        iter (acc *% a)  a' b'
      else
        iter acc a' b' in
  iter 1L a b

let inv a = pw a (md -- 2L)

let () =
  let _ = read_int () in
  let pl = read_line ()
           |> Str.split (Str.regexp " ")
           |> List.map Int64.of_string
           |> List.map (fun p -> p *% (inv 100L)) in
  let (a, b) = List.fold_right
      (fun p (a, b) -> (p *% a ++ 1L, p *% (b -- 1L) ++ 1L))
      pl (0L, 0L) in
  printf "%Ld\n" (a *% (inv (md ++ 1L -- b)))


let l = ref []

let () =
  for i=1 to (read_int ()) do
    l := (Scanf.scanf " %d %d\n%d:%d" (fun x y w z -> x,y,w,z))::!l
  done

let getReflection n =
    match n with
    | 0 | 1 | 8 -> n
    | 2 -> 5
    | 5 -> 2
    | _ -> -1

let checkReflection lh lm h m =
    let hd = getReflection (m mod 10)*10 in
    let hu = getReflection (m / 10) in
    let md = getReflection (h mod 10)*10 in
    let mu = getReflection (h / 10) in
    let hr,mr = ((if ((hd <> -1) && (hu <> -1)) then (hd+hu) else -1), (if (md <> -1) && (mu <> -1) then (md+mu) else -1)) in
    if (hr < lh) && (mr < lm) && (hr >= 0) && (mr >= 0)
    then (hr,mr)
    else (-1,-1)

let checkNextValidReflection lh lm h m =
    let hr,mr = (ref h, ref m) in
    let h,m = (ref h, ref m) in
    let () =
    while (let haux,maux = checkReflection lh lm !h !m in let () = hr := haux in let () = mr := maux in ((!hr = (-1)) && (!mr = (-1)))) do
        if !m < (lm-1)
        then m := !m +1
        else if !h < (lh-1)
            then (h := !h +1; m := 0)
            else (h := 0; m := 0)
    done in
    if !h < 10
    then (Printf.printf "0%d:" !h; if !m < 10 then Printf.printf "0%d\n" !m else Printf.printf "%d\n" !m)
    else (Printf.printf "%d:" !h; if !m < 10 then Printf.printf "0%d\n" !m else Printf.printf "%d\n" !m)

let rec testAll l =
    match l with
    | (lh,lm,h,m)::t -> (testAll t; checkNextValidReflection lh lm h m)
    | [] -> ()

let () = testAll !l

(* https://codeforces.com/contest/1493/problem/B *)

let reverse_digit n =
    match n with
    | 0 -> Some 0
    | 1 -> Some 1
    | 2 -> Some 5
    | 5 -> Some 2
    | 8 -> Some 8
    | 3 | 4 | 6 | 7 | 9 -> None

let reverse_time_opt [hh; mm] =
    let rec helper_opt e acc =
        match e with
        | [] -> Some acc
        | h::t ->
            match reverse_digit h with
            | Some h2 -> helper_opt t (h2::acc)
            | None -> None in
    let rev_minuts = helper_opt mm [] and
    rev_hours = helper_opt hh [] in
    match rev_minuts, rev_hours with
    | Some m, Some h -> Some [m; h]
    | _ -> None

let listify time =
    let rec helper i acc num =
        if i = 2
        then acc
        else helper (i+1) ((num mod 10)::acc) (num/10) in
    List.map (helper 0 []) time

let numberify =
    List.fold_left (fun acc e -> acc * 10 + e) 0

let add_minut h m =
    let inner_add [hh; mm] =
        let minuts = numberify mm and
        hours = numberify hh in
        if minuts + 1 = m
        then (
            let minuts2 = 0 in
            if hours + 1 = h
            then
                let hours2 = 0 in
                listify [hours2; minuts2]
            else listify [hours+1; minuts2]
            )
        else
            listify [hours; minuts+1] in
    inner_add

let correct_time h m =
    let inner_correct t =
        match t with
        | None -> false
        | Some [hh; mm] ->
            numberify hh < h && numberify mm < m in
    inner_correct

let next_time_rev h m time =
    let verify_t = correct_time h m and
    add_m = add_minut h m in
    let rec helper i t =
        if verify_t (reverse_time_opt t)
        then t
        else helper (i+1) (add_m t) in
    helper 0 time

let print_time [hh; mm] =
    List.iter (Printf.printf "%d") hh;
    Printf.printf ":";
    List.iter (Printf.printf "%d") mm

let input_case () =
    let h::m::_ =
        read_line ()
        |> Str.split (Str.regexp " ") |> List.map int_of_string and
    t =
        read_line ()
        |> Str.split (Str.regexp ":") |> List.map int_of_string |> listify in
    (h, m, t)

let () =
    let cases = read_int () in
    for i = 1 to cases do
        let (h, m, t) = input_case () in
        next_time_rev h m t
        |> print_time;
        print_newline ()
    done

let l = ref []

let () =
  for i=1 to (read_int ()) do
    l := (Scanf.scanf " %d %d\n%d:%d" (fun x y w z -> x,y,w,z))::!l
  done

let getReflection n =
    match n with
    | 0 | 1 | 8 -> n
    | 2 -> 5
    | 5 -> 2
    | _ -> -1

let checkReflection lh lm h m =
    let hr,mr = (((getReflection (m mod 10)*10) + (getReflection (m / 10))), ((getReflection (h mod 10)*10) + (getReflection (h / 10)))) in
    if (hr < lh) && (mr < lm) && (hr >= 0) && (mr >= 0)
    then (hr,mr)
    else (-1,-1)

let checkNextValidReflection lh lm h m =
    let hr,mr = (ref h, ref m) in
    let h,m = (ref h, ref m) in
    let () =
    while (let haux,maux = checkReflection lh lm !h !m in let () = hr := haux in let () = mr := maux in ((!hr = (-1)) && (!mr = (-1)))) do
        if !m < (lm-1)
        then m := !m +1
        else if !h < (lh-1)
            then (h := !h +1; m := 0)
            else (h := 0; m := 0)
    done in
    if !h < 10
    then (Printf.printf "0%d:" !h; if !m < 10 then Printf.printf "0%d\n" !m else Printf.printf "%d\n" !m)
    else (Printf.printf "%d:" !h; if !m < 10 then Printf.printf "0%d\n" !m else Printf.printf "%d\n" !m)

let rec testAll l =
    match l with
    | (lh,lm,h,m)::t -> (testAll t; checkNextValidReflection lh lm h m)
    | [] -> ()

let () = testAll !l

let l = ref []

let () =
  for i=1 to (read_int ()) do
    l := (Scanf.scanf " %d %d\n%d:%d" (fun x y w z -> x,y,w,z))::!l
  done

let getReflection n =
    match n with
    | 0 | 1 | 8 -> n
    | 2 -> 5
    | 5 -> 2
    | _ -> -1

let checkReflection lh lm h m =
    let hr,mr = (((getReflection (m mod 10)*10) + (getReflection (m / 10))), ((getReflection (h mod 10)*10) + (getReflection (h / 10)))) in
    if (hr < lh) && (mr < lm) && (hr >= 0) && (mr >= 0)
    then (hr,mr)
    else (-1,-1)

let checkNextValidReflection lh lm h m =
    let hr,mr = (ref h, ref m) in
    let h,m = (ref h, ref m) in
    let () =
    while (let haux,maux = checkReflection lh lm !h !m in let () = hr := haux in let () = mr := maux in ((!hr = (-1)) && (!mr = (-1)))) do
        if !h >= (lh-1) then h:=0 else h := !h+1;
        if !m >= (lm-1) then m:=0 else m := !m+1;
    done in
    if !h < 10
    then (Printf.printf "0%d:" !h; if !m < 10 then Printf.printf "0%d\n" !m else Printf.printf "%d\n" !m)
    else (Printf.printf "%d:" !h; if !m < 10 then Printf.printf "0%d\n" !m else Printf.printf "%d\n" !m)

let rec testAll l =
    match l with
    | (lh,lm,h,m)::t -> (testAll t; checkNextValidReflection lh lm h m)
    | [] -> ()

let () = testAll !l


let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  (*let s = 1000003 in
  let ht = Array.make s 0 in*)
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    let ht = Hashtbl.create n in
    (*let () =
      for i = 0 to s - 1 do
	ht.(i) <- 0
      done
    in
    let hf x y =
      let r = (x * 20000 + y) mod s in
	if r < 0
	then r + s
	else r
    in*)
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let key = (xi, yi) in
	(*let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1*)
	  try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1
      done
    in
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false*)
		  if Hashtbl.mem ht key
		  then remove := false
	      ) else (
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false*)
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
(*if n = 100000 then*)
if n < 100 && Array.length ps = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m; exit 0);
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  Random.init 666666;
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (dup, di, dj) =
    let dup = ref false in
    let di = ref 0 in
    let dj = ref 0 in
    let ht = Hashtbl.create n in
      for i = 0 to n - 1 do
	if Hashtbl.mem ht a.(i) then (
	  dup := true;
	  di := i;
	  dj := Hashtbl.find ht a.(i)
	);
	Hashtbl.replace ht a.(i) i
      done;
      (!dup, !di, !dj)
  in
  let (_, i, j) =
    if dup
    then (0.0, di, dj)
    else cp2d a
  in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let s = 1000003 in
  let ht = Array.make s 0 in
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    let ht = Hashtbl.create n in
    (*let () =
      for i = 0 to s - 1 do
	ht.(i) <- 0
      done
    in*)
    let hf x y =
      let r = (x * 20000 + y) mod s in
	if r < 0
	then r + s
	else r
    in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let key = (xi, yi) in
	(*let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1*)
	  try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1
      done
    in
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false*)
		  if Hashtbl.mem ht key
		  then remove := false
	      ) else (
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false*)
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
(*if n = 100000 then*)
if n < 100 && Array.length ps = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m; exit 0);
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  Random.init 666666;
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (dup, di, dj) =
    let dup = ref false in
    let di = ref 0 in
    let dj = ref 0 in
    let ht = Hashtbl.create n in
      for i = 0 to n - 1 do
	if Hashtbl.mem ht a.(i) then (
	  dup := true;
	  di := i;
	  dj := Hashtbl.find ht a.(i)
	);
	Hashtbl.replace ht a.(i) i
      done;
      (!dup, !di, !dj)
  in
  let (_, i, j) =
    if dup
    then (0.0, di, dj)
    else cp2d a
  in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let ht = Array.make 1000003 0 in
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    (*let ht = Hashtbl.create n in*)
    let () =
      for i = 0 to 1000003 - 1 do
	ht.(i) <- 0
      done
    in
    let hf x y =
      let r = (x * 20000 + y) mod 1000003 in
	if r < 0
	then r + 1000003
	else r
    in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	(*let key = (xi, yi) in*)
	let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1
	  (*try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1*)
      done
    in
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false
		  (*if Hashtbl.mem ht key
		  then remove := false*)
	      ) else (
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false
		(*let key = xi * 20000 + yi in
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false*)
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m; exit 0);
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  Random.init 666666;
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (_, i, j) = cp2d a in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let rec estimate ps =
    let n = Array.length ps in
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    let ht = Hashtbl.create n in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	  try
	    let c = Hashtbl.find ht (xi, yi) in
	      Hashtbl.replace ht (xi, yi) (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht (xi, yi) 1
      done
    in
    let rs = ref [] in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		  if Hashtbl.mem ht (xi, yi)
		  then remove := false
	      ) else (
		let c = Hashtbl.find ht (xi, yi) in
		  if c <> 1
		  then remove := false
	      )
	    done
	  done;
	  if not !remove
	  then rs := ps.(i) :: !rs
      done;
      if !rs = []
      then d
      else estimate (Array.of_list !rs)
  in
  let n = Array.length ps in
  let b = estimate ps in
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	Hashtbl.add ht (xi, yi) i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    let rs = Hashtbl.find_all ht (xi, yi) in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let _ =
  let sb = Scanf.Scanning.stdib in
  let sb = Scanf.Scanning.from_file "input.txt" in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (_, i, j) =
    if n < 100000 then
    cp2d a
    else (0.0, 0, 0)
  in
  let fd = open_out "output.txt" in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let s = 1000003 in
  let ht = Array.make s 0 in
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    let ht = Hashtbl.create n in
    (*let () =
      for i = 0 to s - 1 do
	ht.(i) <- 0
      done
    in*)
    let hf x y =
      let r = (x * 20000 + y) mod s in
	if r < 0
	then r + s
	else r
    in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let key = (xi, yi) in
	(*let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1*)
	  try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1
      done
    in
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false*)
		  if Hashtbl.mem ht key
		  then remove := false
	      ) else (
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false*)
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
(*if n = 100000 then*)
if n < 100000 && Array.length ps = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m; exit 0);
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  Random.init 666666;
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (_, i, j) = cp2d a in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let s = 1000003 in
  let ht = Array.make s 0 in
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    let ht = Hashtbl.create n in
    (*let () =
      for i = 0 to s - 1 do
	ht.(i) <- 0
      done
    in*)
    let hf x y =
      let r = (x * 20000 + y) mod s in
	if r < 0
	then r + s
	else r
    in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let key = (xi, yi) in
	(*let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1*)
	  try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1
      done
    in
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false*)
		  if Hashtbl.mem ht key
		  then remove := false
	      ) else (
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false*)
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
(*if n = 100000 then*)
if Array.length ps = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m);
if n < 100 && Array.length ps = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m; exit 0);
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  Random.init 666666;
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (_, i, j) = cp2d a in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let ht = Array.make 1000003 0 in
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    (*let ht = Hashtbl.create n in*)
    let () =
      for i = 0 to 1000003 - 1 do
	ht.(i) <- 0
      done
    in
    let hf x y =
      let r = (x * 20000 + y) mod 1000003 in
	if r < 0
	then r + 1000003
	else r
    in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	(*let key = (xi, yi) in*)
	let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1
	  (*try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1*)
      done
    in
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false
		  (*if Hashtbl.mem ht key
		  then remove := false*)
	      ) else (
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false
		(*let key = xi * 20000 + yi in
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false*)
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m; exit 0);
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (_, i, j) = cp2d a in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let s = 4000037 in
  let ht = Array.make s 0 in
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    (*let ht = Hashtbl.create n in*)
    let () =
      for i = 0 to s - 1 do
	ht.(i) <- 0
      done
    in
    let hf x y =
      let r = (x * 20000 + y) mod s in
	if r < 0
	then r + s
	else r
    in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	(*let key = (xi, yi) in*)
	let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1
	  (*try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1*)
      done
    in
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false
		  (*if Hashtbl.mem ht key
		  then remove := false*)
	      ) else (
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false
		(*let key = xi * 20000 + yi in
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false*)
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m; exit 0);
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  Random.init 666666;
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (_, i, j) = cp2d a in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let s = 4000037 in
  let ht = Array.make s 0 in
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    (*let ht = Hashtbl.create n in*)
    let () =
      for i = 0 to s - 1 do
	ht.(i) <- 0
      done
    in
    let hf x y =
      let r = (x * 20000 + y) mod s in
	if r < 0
	then r + s
	else r
    in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	(*let key = (xi, yi) in*)
	let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1
	  (*try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1*)
      done
    in
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false
		  (*if Hashtbl.mem ht key
		  then remove := false*)
	      ) else (
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false
		(*let key = xi * 20000 + yi in
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false*)
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
(*if n = 100000 then*)
if n < 100000 && Array.length ps = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m; exit 0);
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  Random.init 666666;
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (_, i, j) = cp2d a in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let ht = Array.make 1000003 0 in
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    (*let ht = Hashtbl.create n in*)
    let () =
      for i = 0 to 1000003 - 1 do
	ht.(i) <- 0
      done
    in
    let hf x y =
      let r = (x * 20000 + y) mod 1000003 in
	if r < 0
	then r + 1000003
	else r
    in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	(*let key = (xi, yi) in*)
	let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1
	  (*try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1*)
      done
    in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false
		  (*if Hashtbl.mem ht key
		  then remove := false*)
	      ) else (
		(*let key = (xi, yi) in*)
		let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false
		(*let key = xi * 20000 + yi in
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false*)
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (_, i, j) = cp2d a in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))

let cp2d ps =
  let sqr x = x *. x in
  let dist (x1, y1) (x2, y2) =
    sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1))
  in
  let s = 1000003 in
  let ht = Array.make s 0 in
  let rec estimate ps n rs =
    let idx = Random.int n in
    let d = ref infinity in
    let () =
      for i = 0 to n - 1 do
	if i <> idx
	then d := min !d (dist ps.(idx) ps.(i))
      done
    in
    let d = !d in
    let b = d /. 3.0 in
    let ht = Hashtbl.create n in
    (*let () =
      for i = 0 to s - 1 do
	ht.(i) <- 0
      done
    in*)
    let hf x y =
      let r = (x * 20000 + y) mod s in
	if r < 0
	then r + s
	else r
    in
    let () =
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let key = (xi, yi) in
	(*let key = hf xi yi in
	  ht.(key) <- ht.(key) + 1*)
	  try
	    let c = Hashtbl.find ht key in
	      Hashtbl.replace ht key (c + 1)
	  with
	    | Not_found ->
		Hashtbl.replace ht key 1
      done
    in
    let m = ref 0 in
      for i = 0 to n - 1 do
	let (x, y) = ps.(i) in
	let xi = int_of_float (x /. b) in
	let yi = int_of_float (y /. b) in
	let remove = ref true in
	  for xd = -1 to 1 do
	    for yd = -1 to 1 do
	      if not (xd = 0 && yd = 0) then (
		let xi = xi + xd in
		let yi = yi + yd in
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) > 0
		  then remove := false*)
		  if Hashtbl.mem ht key
		  then remove := false
	      ) else (
		let key = (xi, yi) in
		(*let key = hf xi yi in
		  if ht.(key) <> 1
		  then remove := false*)
		let c = Hashtbl.find ht key in
		  if c <> 1
		  then remove := false
	      )
	    done
	  done;
	  if not !remove then (
	    rs.(!m) <- ps.(i);
	    incr m
	  )
      done;
(*if n = 100000 then*)
if n < 100 && Array.length ps = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f %d\n%!" b !m; exit 0);
      if !m = 0
      then d
      else estimate rs !m ps
  in
  let n = Array.length ps in
  let b = estimate (Array.copy ps) n (Array.copy ps) in
if n = 100000 then
(Printf.fprintf (open_out "output.txt") "est %f\n%!" b; exit 0);
  let ht = Hashtbl.create n in
  let () =
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
      (*let key = (xi, yi) in*)
      let key = xi * 20000 + yi in
	Hashtbl.add ht key i
    done
  in
  let d = ref infinity in
  let di = ref (-1) in
  let dj = ref (-1) in
    for i = 0 to n - 1 do
      let (x, y) = ps.(i) in
      let xi = int_of_float (x /. b) in
      let yi = int_of_float (y /. b) in
	for xd = -1 to 1 do
	  for yd = -1 to 1 do
	    let xi = xi + xd in
	    let yi = yi + yd in
	    (*let key = (xi, yi) in*)
	    let key = xi * 20000 + yi in
	    let rs = Hashtbl.find_all ht key in
	      List.iter
		(fun j ->
		   if i <> j then (
		     let dd = dist ps.(i) ps.(j) in
		       if dd < !d then (
			 d := dd;
			 di := i;
			 dj := j;
		       )
		   )
		) rs
	  done
	done;
    done;
    (!d, !di, !dj)

let debug = not true

let _ =
  Random.init 666666;
  let sb =
    if debug
    then Scanf.Scanning.stdib
    else Scanf.Scanning.from_file "input.txt"
  in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n (0.0, 0.0) in
  let b = Array.make n 0 in
  let () =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
      let (x, y, r) =
	if x < 0 && y < 0
	then (-x, -y, 4)
	else if x < 0
	then (-x, y, 2)
	else if y < 0
	then (x, -y, 3)
	else (x, y, 1)
      in
	a.(i) <- (float_of_int x, float_of_int y);
	b.(i) <- r
    done;
  in
  let rot r =
    match r with
      | 1 -> 4
      | 2 -> 3
      | 3 -> 2
      | 4 -> 1
      | _ -> assert false
  in
  let (_, i, j) = cp2d a in
  let fd =
    if debug
    then stdout
    else open_out "output.txt"
  in
    Printf.fprintf fd "%d %d %d %d\n" (i + 1) b.(i) (j + 1) (rot b.(j))


let rec is_pow powered n =
	(n = powered) || ((powered mod n = 0) && (is_pow (powered / n) n));;

let f n l =
	let tab = Array.make (n+1) true and compt = ref 0 in
		tab.(0) <- false;
		tab.(1) <- false;
		for i = 2 to n do
			if tab.(i)
				then 	(incr compt;
					l := i:: !l;
					for j = 2 to (n/i) do
						tab.(i*j) <- false;
						if is_pow (i*j) i
							then (l := (i*j):: !l; incr compt);
					done);
		done;
		!compt;;

let main () =
	let l = ref [] in
		Scanf.scanf "%d" (fun i -> Printf.printf "%d\n" (f i l));
		List.iter (Printf.printf "%d ") !l;;

main ();;

let read_int () = Scanf.scanf " %d " (fun x -> x)

let is_prime n =
  let rec go d =
    if d * d > n then true else
      if n mod d = 0 then false else
        go (d+1)
  in
  go 2

let rec gen_primes n ans =
  if n <= 1 then ans else
    if is_prime n then gen_primes (n-1) (n::ans) else
      gen_primes (n-1) ans

let () =
  let n = read_int () in
  let rec f p a b = if b > n then a else (f p (b::a) (b*p)) in
  let g a p = f p a p in
  let ans = List.fold_left g [] (gen_primes n []) in
  Printf.printf "%d\n" (List.length ans);
  List.iter (Printf.printf "%d ") ans;;