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

let _ =
  let sb = Scanf.Scanning.stdib in
  let mm = 1000000007 in
  let mmm = Int64.of_int mm in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let l = Scanf.bscanf sb "%Ld " (fun s -> s) in
  let k = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n 0 in
  let _ =
    for i = 0 to n - 1 do
      a.(i) <- Scanf.bscanf sb "%d " (fun s -> s)
    done;
  in
  let m = l /| (Int64.of_int n) in
  let n' = Int64.to_int (Int64.rem l (Int64.of_int n)) in
  let a' = Array.sub a 0 n' in
  let b = Array.copy a in
  let () = Array.sort compare b in
  let b' = Array.copy a' in
  let () = Array.sort compare b' in
  let bs a x =
    let l = ref (-1) in
    let r = ref (Array.length a) in
      while !l < !r - 1 do
	let m = (!l + !r) lsr 1 in
	  if a.(m) <= x
	  then l := m
	  else r := m
      done;
      !r
  in
  let d = Array.make_matrix n (k + 1) 1 in
  (*let cc = Array.init n (fun i -> bs b a.(i)) in*)
  let _ =
    for j = 1 to k do
      let p = ref 0 in
	for i = 0 to n - 1 do
	  while !p < n && b.(!p) <= b.(i) do
	    incr p;
	  done;
	  d.(i).(j) <-
	    if i = 0
	    then d.(!p - 1).(j - 1)
	    else
	      Int32.to_int
		(Int32.rem
		   (Int32.add
		      (Int32.of_int d.(i - 1).(j))
		      (Int32.of_int d.(!p - 1).(j - 1)))
		   (Int32.of_int mm));
	  (*Printf.printf "zxc %d %d %d\n" i j d.(i).(j)*)
	done
    done;
  in
  let res = ref 0L in
    for i = 0 to n' - 1 do
      let c = bs b a.(i) in
	(*Printf.printf "asd %d %d %d\n" i a.(i) c;*)
	for kk = 1 to k do
	  let k = kk - 1 in
	    if Int64.of_int k <= m then (
	      res :=
		Int64.rem
		  (!res +|
		       (*Int64.of_int bmk.(k) *| *)
			   Int64.of_int d.(c - 1).(k)) mmm;
	      (*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
	    )
	done;
    done;
    for kk = 1 to k do
      let k = kk in
	if Int64.of_int k <= m then (
	  res :=
	    Int64.rem
	      (!res +|
		   Int64.rem (m -| Int64.of_int (k - 1)) mmm *|
		       Int64.of_int d.(n - 1).(k)) mmm;
	  (*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
	)
    done;
    Printf.printf "%Ld\n" !res

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

let m = 1_000_000_007

let ( ++ ) a b = Int64.add a b
let ( -- ) a b = Int64.sub a b
let ( ** ) a b = Int64.mul a b
let ( // ) a b = Int64.div a b
let ( %% ) a b = Int64.rem a b

let ll a = Int64.of_int a

let add a b = Int64.to_int (((ll a) ++ (ll b)) %% (ll m))

let () =
  let n = read_int () in
  let l = Int64.of_string (read_string ()) in
  let k = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  let sorted = Array.init n (fun i -> (a.(i), i)) in
  Array.sort (fun a b -> (fst a) - (fst b)) sorted;

  let f = Array.make_matrix (k+1) n 0 in
  for j = 0 to n-1 do
    f.(1).(j) <- 1
  done;

  for i = 2 to k do
    let sum = ref 0 in
    let l = ref 0 in
    while !l < n do
      let r = ref !l in
      while !r < n && (fst sorted.(!r)) = (fst sorted.(!l)) do
        sum := add !sum f.(i-1).(snd sorted.(!r));
        r := !r + 1
      done;
      while !l < !r do
        f.(i).(snd sorted.(!l)) <- !sum;
        l := !l + 1
      done;
    done;
  done;

  let ans = ref 0 in
  for i = 1 to k do
    for j = 0 to n-1 do
      let len = ((ll (i-1)) ** (ll n)) ++ (ll (j+1)) in
      let ways = (l -- len ++ (ll n)) // (ll n) %% (ll m) in
      let llf = ll f.(i).(j) in
      let total = (ways ** llf) %% (ll m) in
      if len <= l then ans := add !ans (Int64.to_int total)
    done;
  done;

  Printf.printf "%d\n" !ans
;;

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

let _ =
  let sb = Scanf.Scanning.stdib in
  let mm = 1000000007 in
  let mmm = Int64.of_int mm in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let l = Scanf.bscanf sb "%Ld " (fun s -> s) in
  let k = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n 0 in
  let _ =
    for i = 0 to n - 1 do
      a.(i) <- Scanf.bscanf sb "%d " (fun s -> s)
    done;
  in
  let inv = Array.make 1000001 1 in
  let _ =
    for i = 2 to 1000000 do
      inv.(i) <-
	Int64.to_int
	(Int64.rem
	   (mmm -| Int64.rem (Int64.of_int (mm / i) *| Int64.of_int inv.(mm mod i)) mmm)
	   mmm);
    done
  in
  let fact = Array.make (n + k + 2) 1 in
  let ifact = Array.make (n + k + 2) 1 in
  let () =
    for i = 2 to n + k + 1 do
      fact.(i) <-
	Int64.to_int
	(Int64.rem
	   (Int64.of_int fact.(i - 1) *| Int64.of_int i) mmm);
      ifact.(i) <-
	Int64.to_int
	(Int64.rem
	   (Int64.of_int ifact.(i - 1) *| Int64.of_int inv.(i)) mmm);
    done;
  in
  let binom n k =
    Int64.to_int
      (Int64.rem
	 (Int64.rem (Int64.of_int fact.(n) *| Int64.of_int ifact.(n - k)) mmm *|
	      Int64.of_int ifact.(k)) mmm)
  in
  (*let binomial = Array.make_matrix (n + k + 1) (k + 1) 0 in
  let _ =
    binomial.(0).(0) <- 1;
    for i = 1 to n + k do
      binomial.(i).(0) <- 1;
      for j = 1 to k do
	binomial.(i).(j) <-
	  (Int32.to_int
	     (Int32.rem
		(Int32.add
		   (Int32.of_int binomial.(i - 1).(j - 1))
		   (Int32.of_int binomial.(i - 1).(j)))
		(Int32.of_int mm)))
      done
    done
  in*)
  let m = l /| (Int64.of_int n) in
  let bmk = Array.make (k + 1) 1 in
  let _ =
    let m = Int64.rem m mmm in
      for i = 1 to k do
	bmk.(i) <-
	  Int64.to_int
	  (Int64.rem
	     (Int64.rem
		(Int64.of_int bmk.(i - 1) *| (m -| Int64.of_int (i - 1))) mmm *|
		    Int64.of_int inv.(i))
	     mmm);
	(*Printf.printf "qwe %Ld %d %d %d\n" m i bmk.(i) inv.(i)*)
      done;
  in
  let n' = Int64.to_int (Int64.rem l (Int64.of_int n)) in
  let a' = Array.sub a 0 n' in
  let b = Array.copy a in
  let () = Array.sort compare b in
  let b' = Array.copy a' in
  let () = Array.sort compare b' in
  let bs a x =
    let l = ref (-1) in
    let r = ref (Array.length a) in
      while !l < !r - 1 do
	let m = (!l + !r) lsr 1 in
	  if a.(m) <= x
	  then l := m
	  else r := m
      done;
      !r
  in
  let res = ref 0L in
    for i = 0 to n' - 1 do
      let c = bs b a.(i) in
	(*Printf.printf "asd %d %d %d\n" i a.(i) c;*)
	for kk = 1 to k do
	  let k = kk - 1 in
	    res :=
	      Int64.rem
		(!res +|
		     Int64.of_int bmk.(k) *|
			 Int64.of_int (binom (c + k - 1) k)) mmm;
	    (*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
	done;
    done;
    for kk = 1 to k do
      let k = kk in
	res :=
	  Int64.rem
	    (!res +|
		 Int64.of_int bmk.(k) *|
		     Int64.of_int (binom (n + k - 1) k)) mmm;
	(*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
    done;
    Printf.printf "%Ld\n" !res

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

let _ =
  let sb = Scanf.Scanning.stdib in
  let mm = 1000000007 in
  let mmm = Int64.of_int mm in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let l = Scanf.bscanf sb "%Ld " (fun s -> s) in
  let k = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n 0 in
  let _ =
    for i = 0 to n - 1 do
      a.(i) <- Scanf.bscanf sb "%d " (fun s -> s)
    done;
  in
  let inv = Array.make 1000001 1 in
  let _ =
    for i = 2 to 1000000 do
      inv.(i) <-
	Int64.to_int
	(Int64.rem
	   (mmm -| Int64.rem (Int64.of_int (mm / i) *| Int64.of_int inv.(mm mod i)) mmm)
	   mmm);
    done
  in
  let m = l /| (Int64.of_int n) in
  let bmk = Array.make (k + 1) 1 in
  let _ =
    let m = Int64.rem m mmm in
      for i = 1 to k do
	bmk.(i) <-
	  Int64.to_int
	  (Int64.rem
	     (Int64.rem
		(Int64.of_int bmk.(i - 1) *| (m -| Int64.of_int (i - 1))) mmm *|
		    Int64.of_int inv.(i))
	     mmm);
	(*Printf.printf "qwe %Ld %d %d %d\n" m i bmk.(i) inv.(i)*)
      done;
  in
  let n' = Int64.to_int (Int64.rem l (Int64.of_int n)) in
  let a' = Array.sub a 0 n' in
  let b = Array.copy a in
  let () = Array.sort compare b in
  let b' = Array.copy a' in
  let () = Array.sort compare b' in
  let bs a x =
    let l = ref (-1) in
    let r = ref (Array.length a) in
      while !l < !r - 1 do
	let m = (!l + !r) lsr 1 in
	  if a.(m) <= x
	  then l := m
	  else r := m
      done;
      !r
  in
  let d = Array.make_matrix n (k + 1) 1 in
  (*let cc = Array.init n (fun i -> bs b a.(i)) in*)
  let _ =
    for j = 1 to k do
      let p = ref 0 in
	for i = 0 to n - 1 do
	  while !p < n && b.(!p) <= b.(i) do
	    incr p;
	  done;
	  d.(i).(j) <-
	    if i = 0
	    then d.(!p - 1).(j - 1)
	    else
	      Int32.to_int
		(Int32.rem
		   (Int32.add
		      (Int32.of_int d.(i - 1).(j))
		      (Int32.of_int d.(!p - 1).(j - 1)))
		   (Int32.of_int mm));
	  (*Printf.printf "zxc %d %d %d\n" i j d.(i).(j)*)
	done
    done;
  in
  let res = ref 0L in
    for i = 0 to n' - 1 do
      let c = bs b a.(i) in
	(*Printf.printf "asd %d %d %d\n" i a.(i) c;*)
	for kk = 1 to k do
	  let k = kk - 1 in
	    if Int64.of_int k <= m then (
	      res :=
		Int64.rem
		  (!res +|
		       (*Int64.of_int bmk.(k) *| *)
			   Int64.of_int d.(c - 1).(k)) mmm;
	      (*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
	    )
	done;
    done;
    for kk = 1 to k do
      let k = kk in
	if Int64.of_int k <= m then (
	  res :=
	    Int64.rem
	      (!res +|
		   (m -| Int64.of_int (k - 1)) *|
		       Int64.of_int d.(n - 1).(k)) mmm;
	  (*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
	)
    done;
    Printf.printf "%Ld\n" !res

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

let _ =
  let sb = Scanf.Scanning.stdib in
  let mm = 1000000007 in
  let mmm = Int64.of_int mm in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let l = Scanf.bscanf sb "%Ld " (fun s -> s) in
  let k = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n 0 in
  let _ =
    for i = 0 to n - 1 do
      a.(i) <- Scanf.bscanf sb "%d " (fun s -> s)
    done;
  in
  let inv = Array.make 1000001 1 in
  let _ =
    for i = 2 to 1000000 do
      inv.(i) <-
	Int64.to_int
	(Int64.rem
	   (mmm -| Int64.rem (Int64.of_int (mm / i) *| Int64.of_int inv.(mm mod i)) mmm)
	   mmm);
    done
  in
  let fact = Array.make (n + k + 2) 1 in
  let ifact = Array.make (n + k + 2) 1 in
  let () =
    for i = 2 to n + k + 1 do
      fact.(i) <-
	Int64.to_int
	(Int64.rem
	   (Int64.of_int fact.(i - 1) *| Int64.of_int i) mmm);
      ifact.(i) <-
	Int64.to_int
	(Int64.rem
	   (Int64.of_int ifact.(i - 1) *| Int64.of_int inv.(i)) mmm);
    done;
  in
  let binom n k =
    Int64.to_int
      (Int64.rem
	 (Int64.rem (Int64.of_int fact.(n) *| Int64.of_int ifact.(n - k)) mmm *|
	      Int64.of_int ifact.(k)) mmm)
  in
  (*let binomial = Array.make_matrix (n + k + 1) (k + 1) 0 in
  let _ =
    binomial.(0).(0) <- 1;
    for i = 1 to n + k do
      binomial.(i).(0) <- 1;
      for j = 1 to k do
	binomial.(i).(j) <-
	  (Int32.to_int
	     (Int32.rem
		(Int32.add
		   (Int32.of_int binomial.(i - 1).(j - 1))
		   (Int32.of_int binomial.(i - 1).(j)))
		(Int32.of_int mm)))
      done
    done
  in*)
  let m = l /| (Int64.of_int n) in
  let bmk = Array.make (k + 1) 1 in
  let _ =
    let m = Int64.rem m mmm in
      for i = 1 to k do
	bmk.(i) <-
	  Int64.to_int
	  (Int64.rem
	     (Int64.rem
		(Int64.of_int bmk.(i - 1) *| (m -| Int64.of_int (i - 1))) mmm *|
		    Int64.of_int inv.(i))
	     mmm);
	(*Printf.printf "qwe %Ld %d %d %d\n" m i bmk.(i) inv.(i)*)
      done;
  in
  let n' = Int64.to_int (Int64.rem l (Int64.of_int n)) in
  let a' = Array.sub a 0 n' in
  let b = Array.copy a in
  let () = Array.sort compare b in
  let b' = Array.copy a' in
  let () = Array.sort compare b' in
  let bs a x =
    let l = ref (-1) in
    let r = ref (Array.length a) in
      while !l < !r - 1 do
	let m = (!l + !r) lsr 1 in
	  if a.(m) <= x
	  then l := m
	  else r := m
      done;
      !r
  in
  let d = Array.make_matrix n (k + 1) 1 in
  (*let cc = Array.init n (fun i -> bs b a.(i)) in*)
  let _ =
    d.(0).(0) <- 1;
    for j = 1 to k do
      let p = ref 0 in
	for i = 0 to n - 1 do
	  while !p < n && b.(!p) <= b.(i) do
	    incr p;
	  done;
	  d.(i).(j) <-
	    if i = 0
	    then d.(!p - 1).(j - 1)
	    else
	      Int32.to_int
		(Int32.rem
		   (Int32.add
		      (Int32.of_int d.(i - 1).(j))
		      (Int32.of_int d.(!p - 1).(j - 1)))
		   (Int32.of_int mm));
	  (*Printf.printf "zxc %d %d %d\n" i j d.(i).(j)*)
	done
    done;
  in
  let res = ref 0L in
    for i = 0 to n' - 1 do
      let c = bs b a.(i) in
	(*Printf.printf "asd %d %d %d\n" i a.(i) c;*)
	for kk = 1 to k do
	  let k = kk - 1 in
	    res :=
	      Int64.rem
		(!res +|
		     Int64.of_int bmk.(k) *|
			 Int64.of_int d.(c - 1).(k)) mmm;
	    (*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
	done;
    done;
    for kk = 1 to k do
      let k = kk in
	res :=
	  Int64.rem
	    (!res +|
		 Int64.of_int bmk.(k) *|
		     Int64.of_int d.(n - 1).(k)) mmm;
	(*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
    done;
    Printf.printf "%Ld\n" !res

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

let _ =
  let sb = Scanf.Scanning.stdib in
  let mm = 1000000007 in
  let mmm = Int64.of_int mm in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let l = Scanf.bscanf sb "%Ld " (fun s -> s) in
  let k = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make n 0 in
  let _ =
    for i = 0 to n - 1 do
      a.(i) <- Scanf.bscanf sb "%d " (fun s -> s)
    done;
  in
  let inv = Array.make 1000001 1 in
  let _ =
    for i = 2 to 1000000 do
      inv.(i) <-
	Int64.to_int
	(Int64.rem
	   (mmm -| Int64.rem (Int64.of_int (mm / i) *| Int64.of_int inv.(mm mod i)) mmm)
	   mmm);
    done
  in
  let fact = Array.make (n + k + 2) 1 in
  let ifact = Array.make (n + k + 2) 1 in
  let () =
    for i = 2 to n + k + 1 do
      fact.(i) <-
	Int64.to_int
	(Int64.rem
	   (Int64.of_int fact.(i - 1) *| Int64.of_int i) mmm);
      ifact.(i) <-
	Int64.to_int
	(Int64.rem
	   (Int64.of_int ifact.(i - 1) *| Int64.of_int inv.(i)) mmm);
    done;
  in
  let binom n k =
    Int64.to_int
      (Int64.rem
	 (Int64.rem (Int64.of_int fact.(n) *| Int64.of_int ifact.(n - k)) mmm *|
	      Int64.of_int ifact.(k)) mmm)
  in
  (*let binomial = Array.make_matrix (n + k + 1) (k + 1) 0 in
  let _ =
    binomial.(0).(0) <- 1;
    for i = 1 to n + k do
      binomial.(i).(0) <- 1;
      for j = 1 to k do
	binomial.(i).(j) <-
	  (Int32.to_int
	     (Int32.rem
		(Int32.add
		   (Int32.of_int binomial.(i - 1).(j - 1))
		   (Int32.of_int binomial.(i - 1).(j)))
		(Int32.of_int mm)))
      done
    done
  in*)
  let m = l /| (Int64.of_int n) in
  let bmk = Array.make (k + 1) 1 in
  let _ =
    let m = Int64.rem m mmm in
      for i = 1 to k do
	bmk.(i) <-
	  Int64.to_int
	  (Int64.rem
	     (Int64.rem
		(Int64.of_int bmk.(i - 1) *| (m -| Int64.of_int (i - 1))) mmm *|
		    Int64.of_int inv.(i))
	     mmm);
	(*Printf.printf "qwe %Ld %d %d %d\n" m i bmk.(i) inv.(i)*)
      done;
  in
  let n' = Int64.to_int (Int64.rem l (Int64.of_int n)) in
  let a' = Array.sub a 0 n' in
  let b = Array.copy a in
  let () = Array.sort compare b in
  let b' = Array.copy a' in
  let () = Array.sort compare b' in
  let bs a x =
    let l = ref (-1) in
    let r = ref (Array.length a) in
      while !l < !r - 1 do
	let m = (!l + !r) lsr 1 in
	  if a.(m) <= x
	  then l := m
	  else r := m
      done;
      !r
  in
  let d = Array.make_matrix n (k + 1) 1 in
  (*let cc = Array.init n (fun i -> bs b a.(i)) in*)
  let _ =
    d.(0).(0) <- 1;
    for j = 1 to k do
      let p = ref 0 in
	for i = 0 to n - 1 do
	  while !p < n && b.(!p) <= b.(i) do
	    incr p;
	  done;
	  d.(i).(j) <-
	    if i = 0
	    then d.(!p - 1).(j - 1)
	    else
	      Int32.to_int
		(Int32.rem
		   (Int32.add
		      (Int32.of_int d.(i - 1).(j))
		      (Int32.of_int d.(!p - 1).(j - 1)))
		   (Int32.of_int mm));
	  (*Printf.printf "zxc %d %d %d\n" i j d.(i).(j)*)
	done
    done;
  in
  let res = ref 0L in
    for i = 0 to n' - 1 do
      let c = bs b a.(i) in
	(*Printf.printf "asd %d %d %d\n" i a.(i) c;*)
	for kk = 1 to k do
	  let k = kk - 1 in
	    res :=
	      Int64.rem
		(!res +|
		     Int64.of_int bmk.(k) *|
			 Int64.of_int (binom (c + k - 1) k)) mmm;
	    (*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
	done;
    done;
    for kk = 1 to k do
      let k = kk in
	res :=
	  Int64.rem
	    (!res +|
		 Int64.of_int bmk.(k) *|
		     Int64.of_int d.(n - 1).(k)) mmm;
	(*Printf.printf "qwe %d %Ld %d\n" k !res bmk.(k)*)
    done;
    Printf.printf "%Ld\n" !res

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

let m = 1_000_000_007

let ( ++ ) a b = Int64.add a b
let ( -- ) a b = Int64.sub a b
let ( ** ) a b = Int64.mul a b
let ( // ) a b = Int64.div a b
let ( %% ) a b = Int64.rem a b

let ll a = Int64.of_int a

let () =
  let n = read_int () in
  let l = Int64.of_string (read_string ()) in
  let k = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  let sorted = Array.init n (fun i -> (a.(i), i)) in
  Array.sort (fun a b -> (fst a) - (fst b)) sorted;

  let f = Array.make_matrix (k+1) n 0 in
  for j = 0 to n-1 do
    f.(1).(j) <- 1
  done;

  for i = 2 to k do
    let sum = ref 0 in
    let l = ref 0 in
    while !l < n do
      let r = ref !l in
      while !r < n && (fst sorted.(!r)) = (fst sorted.(!l)) do
        sum := (!sum + f.(i-1).(snd sorted.(!r))) mod m;
        r := !r + 1
      done;
      while !l < !r do
        f.(i).(snd sorted.(!l)) <- !sum;
        l := !l + 1
      done;
    done;
  done;

  let ans = ref 0 in
  for i = 1 to k do
    for j = 0 to n-1 do
      let len = ((ll (i-1)) ** (ll n)) ++ (ll (j+1)) in
      let ways = (l -- len ++ (ll n)) // (ll n) %% (ll m) in
      let llf = ll f.(i).(j) in
      let total = (ways ** llf) %% (ll m) in
      if len <= l then ans := (!ans + (Int64.to_int total)) mod m
    done;
  done;

  Printf.printf "%d\n" !ans
;;


(* Codeforces 246B *)

let gr () = Scanf.scanf " %d" (fun i -> i)
let rec readline n li = match n with
	| 0 -> li
	| _ -> readline (n-1) (gr () :: li);;

let rec sum l = match l with
	| [] -> 0
	| h :: t -> h + (sum t);;

let main () =
	let n = gr () in
	let ll = readline n [] in
	let sm = sum ll in
	let ret = if (sm mod n) = 0 then n else n -1 in
	(* print_string "sm: ";   *)
	(* print_int sm;          *)
	(* print_string " ret: "; *)
	print_int ret;;

main();;

let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)

let rec fold i j f init = if i>j then init else fold (i+1) j f (f i init)
let sum i j f = fold i j (fun i a -> (f i) + a) 0

let () =
  let n = read_int() in
  let a = Array.init n (fun i -> read_int()) in
  let s =  sum 0 (n-1) (fun i -> a.(i)) in
  let a = if s mod n = 0 then n else (n-1) in
    Printf.printf "%d\n" a

(* Codeforces 246B *)

let gr () = Scanf.scanf " %d" (fun i -> i)
let rec readline n li = match n with
	| 0 -> li
	| _ -> readline (n-1) (gr () :: li);;

let rec sum l = match l with
	| [] -> 0
	| h :: t -> h + (sum t);;

let main () =
	let n = gr () in
	let ll = readline n [] in
	let sm = sum ll in
	let ret = if (sm mod n) = 0 then n else n -1 in
	print_string "sm: ";
	print_int sm;
	print_string " ret: ";
	print_int ret;;

main();;

(* Codeforces 246B *)

let gr () = Scanf.scanf " %d" (fun i -> i)
let readline n li = match n with
	| 0 -> li
	| _ -> gr () :: li;;

let rec sum l = match l with
	| [] -> 0
	| h :: t -> h + (sum t);;

let main () =
	let n = gr () in
	let ll = readline n [] in
	let sm = sum ll in
	let ret = if (sm mod n) = 0 then n else n -1 in
	print_int ret;;

main();;


(* equivalent to 1061C's solution with n,m are maximized *)
let divisors n =
  let rec f0 i a =
    if i*i > n then a
    else if i*i = n && n mod i = 0 then i::a
    else if n mod i = 0 then f0 (i+1) (i::(n/i)::a)
    else f0 (i+1) a
  in f0 1 []
let (++) u v = Int64.rem (Int64.add u v) 1000000007L
external id : 'a -> 'a = "%identity"
let n = Scanf.scanf " %d" @@ id
let a = Array.init n (fun _ -> Scanf.scanf " %d" @@ id)
let dp = Array.make 1000007 0L
let () =
  Array.iter (fun v ->
    divisors v
    |> List.sort (fun u v -> compare v u)
    |> List.iter (fun d ->
      if d=1 then dp.(1) <- dp.(1) ++ 1L
      else dp.(d) <- dp.(d) ++ dp.(d-1)
    )
  ) a;
  Printf.printf "%Ld\n" @@ Array.fold_left (++) 0L dp

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 divisors v =
  let rec f0 i a =
    if i*i > v then a
    else if i*i = v && v mod i = 0L then i::a
    else if v mod i = 0L then f0 (i+1L) (i::(v/i)::a)
    else f0 (i+1L) a in f0 1L [] *)
let divisors n =
  let rec f0 i a =
    if i*$i > n then a
    else if i*$i = n && n %$ i = 0 then i::a
    else if n %$ i = 0 then f0 (i+$1) (i::(n/$i)::a)
    else f0 (i+$1) a
  in f0 1 []
let n = get_i64 0
let a = input_i64_array n
let dp = make 1000007 0L
let (++) u v = (u+v) mod 1000000007L
let () =
  iter (fun v ->
    i32 v
    |> divisors
    |> List.sort (fun u v -> compare v u)
    |> List.iter (fun d ->
      if d=1 then dp.(1) <- dp.(1) ++ 1L
      else dp.(d) <- dp.(d) ++ dp.(d-$1)
    )
  ) a;
  printf "%Ld\n" @@ fold_left (++) 0L dp


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

let n = scan_int ();;
let a = Array.make n 0;;
for i = 0 to (n - 1) do
  a.(i) <- (scan_int ());
done

let k = ref 0;;
for i = 1 to (n - 2) do
  if a.(i - 1) = 1 && a.(i) = 0 && a.(i + 1) = 1 then
  begin
    a.(i + 1) <- 0;
    incr k;
  end;
done;;
print_int !k;;
print_endline "";;

(* Problem 2 of round 521*)
open Scanf;;
open String;;
open Num;;

(*These are some utility functions*)
module U = struct
  let mprint z =
    print_endline (Num.string_of_num z);;

  let read_one format =
    let n = Scanf.scanf format (fun x -> x) in
    n;;

  let read_one_number () =
    let n = read_one "%d " in
    n

  let read_array n a =
    for i = 0 to n - 1 do
      let n = read_one_number () in
      a.(i) <- n
    done

end

(*The solutions*)

let n = U.read_one_number ()
let a = Array.make n 0
let () = U.read_array n a

(*test
let () =
  Array.iter (fun x-> print_int x; print_endline "" ) a
*)
let () =
  let t = ref 0 in
  for i = 1 to n-2 do
    if a.(i)==0 then
      begin
        if a.(i-1)==1 && a.(i+1)==1 then
          begin
            a.(i+1) <- 0;
            incr t
          end
      end
  done;
  print_int !t; print_endline ""

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 = get_i64 0 in
  let a = input_i64_array n in
  let r = ref 0L in
  rep 1L (n-2L) (fun i ->
    let i = i32 i in
    if a.(i-$1)=1L && a.(i)=0L && a.(i+$1)=1L then (
      r += 1L;
      a.(i+$1) <- 0L;
    )
  );
  printf "%Ld\n" !r


let is_right_neighbor a b = (fst a) > (fst b) && (snd a) = (snd b)
let is_left_neighbor a b = (fst a) < (fst b) && (snd a) = (snd b)
let is_lower_neighbor a b = (fst a) = (fst b) && (snd a) < (snd b)
let is_upper_neighbor a b = (fst a) = (fst b) && (snd a) > (snd b)

let is_supercentral_point p points =
  List.exists (is_right_neighbor p) points &&
  List.exists (is_left_neighbor p) points &&
  List.exists (is_lower_neighbor p) points &&
  List.exists (is_upper_neighbor p) points

let solve points =
  let count accum p =
    if is_supercentral_point p points then accum+1
    else accum
  in
  List.fold_left count 0 points

let rec read_n_tuples n lst =
  if n = 0 then lst
  else read_n_tuples (n-1) ((Scanf.scanf " %d %d" (fun x y -> (x, y))) :: lst)

let _ =
  let n = Scanf.scanf " %d" (fun x -> x) in
  let points = read_n_tuples n [] in
  Printf.printf "%d\n" (solve points)

let _ =
    let main () =
        let n = read_int () in
        let arr = Array.init n (fun i -> Scanf.sscanf (read_line ()) "%d %d" (fun x y -> x, y)) in
        let bits = Array.create n 0 in
        Array.iteri (fun i (x, y) ->
            Array.iteri (fun j (a, b) ->
                if a > x && y = b then bits.(j) <- bits.(j) lor 1;
                if a < x && y = b then bits.(j) <- bits.(j) lor 2;
                if a = x && y < b then bits.(j) <- bits.(j) lor 4;
                if a = x && y > b then bits.(j) <- bits.(j) lor 8;
            ) arr
        ) arr;
        Printf.printf "%d\n" (Array.fold_left (fun acc k -> acc + k / 15) 0 bits)
    in
    main ()

open Array;;
(* Common part*)
let (|>) x f = f x
let identity = fun x -> x

let flip f y x = f x y

let readInStr _ = Scanf.scanf "%d " identity
let readIntLn _ = Scanf.scanf "%d\n" identity
(*      Programme       *)
let f x y = match x, y with (x,y,_), (x1,y1,_) ->  if x=x1 then y-y1 else x-x1
let f1 x y = match x, y with (x,y,_), (x1,y1,_) -> if y=y1 then x-x1 else y-y1

let y arr n i = if i>=n then function _-> ()
  else function (x,y,z) ->
    match arr.(i+1)
    with (x1,y1,z1) when x1=x -> arr.(i)<-(x,y,z+1); arr.(i+1) <- (x1,y1,z1+1)
    | _ -> ()

let y1 arr n i = if i>=n then function _-> ()
  else function (x,y,z) ->
    match arr.(i+1)
    with (x1,y1,z1) when y=y1 -> arr.(i)<-(x,y,z+1); arr.(i+1) <- (x1,y1,z1+1)
    | _ -> ()

let main () =
  let n = readIntLn () in
  let arr = init n (function _ -> let a= readInStr () in (a, readIntLn (), 0) ) in
  fast_sort f arr;
   iteri (n-1|>y arr) arr;
  fast_sort f1 arr;
   iteri (n-1|>y1 arr) arr;
   fold_left (fun acc-> function (_,_,z) -> if z = 4 then (acc+1) else acc ) 0 arr |> print_int;
  ;;
main()

open Array;;
(* Common part*)
let (|>) x f = f x
let identity = fun x -> x

let flip f y x = f x y

let readInStr _ = Scanf.scanf "%d " identity
let readIntLn _ = Scanf.scanf "%d\n" identity
(*      Programme       *)
let f x y = match x, y with (x,y,z), (x1,y1,z1) ->  if x=x1 then y-y1 else x-x1

let y arr n i = if i>=n then function _-> ()
  else function (x,y,z) ->
    match arr.(i+1)
    with (x1,y1,z1) when x1=x -> arr.(i)<-(x,y,z+1); arr.(i+1) <- (x1,y1,z1+1)
    | _ -> ()

let main () =
  let n = readIntLn () in
  let arr = init n (function _ -> let a= readInStr () in (a, readIntLn (), 0) ) in
  fast_sort f arr;
   iteri (n-1|>y arr) arr;
  fast_sort (flip f) arr;
   iteri (n-1|>y arr) arr;
   fold_left (fun acc-> function (_,_,z) -> if z = 4 then (acc+1) else acc ) 0 arr |> print_int;
  ;;
main()


open Str;;
open Array;;
open String;;

let split sep =
	let re = Str.regexp sep in
	Str.split re
;;

let rec range a b =
	if a = b then [] else a :: range (a+1) b
;;

let (!!) ls n =
	List.nth ls n
;;

let main =
	let len = read_int()
	and nums = Array.map float_of_string (Array.of_list (split " " (read_line()))) in
	let sum = Array.fold_left (+.) 0. nums in
	let ln = ref 0 in
	let indexes = Array.mapi (fun i x ->
		if (sum -. x) /. (float_of_int (len-1)) = x then begin
			incr ln;
			i + 1
		end else
			0
	) nums in
	let _ = print_int (!ln) in
	let _ = print_string "\n" in
	Array.iter (fun i ->
		if i > 0 then
			let _ = print_int i in
			print_string " "
	) indexes
;;

let rec input_seq n lst =
  if n <= 1 then (Scanf.scanf "%d\n" (fun x -> x)) :: lst
  else input_seq (n - 1) ((Scanf.scanf "%d " (fun x -> x)) :: lst)

let input_seq n = List.rev (input_seq n [])

let solve n =
  let seq = input_seq n in
  let sum = List.fold_left (+) 0 seq in
  let rec loop lst accm cnt = match lst with
    | [] -> accm
    | first :: rest
	-> if first * n == sum then loop rest (cnt::accm) (cnt+1)
	  else loop rest accm (cnt+1)
  in
  loop seq [] 1

let rec print_int_list = function
  | [] -> Printf.printf "\n"
  | lst :: [] -> Printf.printf "%d\n" lst
  | first :: rest ->
    begin
      Printf.printf "%d " first;
      print_int_list rest
    end

let _ =
  let ans = Scanf.scanf "%d\n" solve in
  Printf.printf "%d\n" (List.length ans);
  if List.length ans != 0 then print_int_list (List.rev ans)

open Str;;
open Array;;
open String;;

let split sep =
	let re = Str.regexp sep in
	Str.split re
;;

let rec range a b =
	if a = b then [] else a :: range (a+1) b
;;

let (!!) ls n =
	List.nth ls n
;;

let main =
	let len = read_int()
	and nums = Array.map float_of_string (Array.of_list (split " " (read_line()))) in
	let sum = Array.fold_left (+.) 0. nums in
	let indexes = List.filter (fun i ->
		(sum -. nums.(i)) /. (float_of_int (len-1)) = nums.(i)
	) (range 0 len) in
	let _ = print_int (List.length indexes) in
	let _ = print_string "\n" in
	print_string (String.concat " " (List.map (fun x ->string_of_int (x+1)) indexes))
;;

open Str;;
open List;;

let split sep =
	let re = Str.regexp sep in
	Str.split re
;;

let rec range a b =
	if a = b then [] else a :: range (a+1) b
;;

let (!!) ls n =
	List.nth ls n
;;

let main =
	let len = read_int()
	and nums = List.map float_of_string (split " " (read_line())) in
	let sum = List.fold_left (+.) 0. nums in
	let avg = sum /. (float_of_int len) in
	let indexes = List.filter (fun i ->
		(sum -. (List.nth nums i)) /. (float_of_int (len-1)) = List.nth nums i
	) (range 0 len) in
	let _ = print_int (List.length indexes) in
	let _ = print_string "\n" in
	List.iter (fun i -> print_int (i+1); print_string " ") indexes
;;

open Str;;
open List;;

let split sep =
	let re = Str.regexp sep in
	Str.split re
;;

let rec range a b =
	if a = b then [] else a :: range (a+1) b
;;

let (!!) ls n =
	List.nth ls n
;;

let main =
	let len = read_int()
	and nums = List.map int_of_string (split " " (read_line())) in
	let sum = List.fold_left (+) 0 nums in
	let avg = sum / len in
	let indexes = List.filter (fun i ->
		avg = List.nth nums i
	) (range 0 len) in
	let _ = print_int (List.length indexes) in
	let _ = print_string "\n" in
	List.iter (fun i -> print_int (i+1); print_string " ") indexes
;;

open Str;;
open List;;
open String;;

let split sep =
	let re = Str.regexp sep in
	Str.split re
;;

let rec range a b =
	if a = b then [] else a :: range (a+1) b
;;

let (!!) ls n =
	List.nth ls n
;;

let main =
	let len = read_int()
	and nums = List.map float_of_string (split " " (read_line())) in
	let sum = List.fold_left (+.) 0. nums in
	let avg = sum /. (float_of_int len) in
	let indexes = List.filter (fun i ->
		(sum -. (List.nth nums i)) /. (float_of_int (len-1)) = List.nth nums i
	) (range 0 len) in
	let _ = print_int (List.length indexes) in
	let _ = print_string "\n" in
	print_string (String.concat " " (List.map (fun x ->string_of_int (x+1)) indexes))
;;

let rec input_seq n lst =
  if n <= 1 then (Scanf.scanf "%d\n" (fun x -> x)) :: lst
  else input_seq (n - 1) ((Scanf.scanf "%d " (fun x -> x)) :: lst)

let input_seq n = List.rev (input_seq n [])

let solve n =
  let seq = input_seq n in
  let sum = List.fold_left (+) 0 seq in
  let rec loop lst accm cnt = match lst with
    | [] -> accm
    | first :: rest
	-> if (sum-first) / (n - 1) == first then loop rest (cnt::accm) (cnt+1)
	  else loop rest accm (cnt+1)
  in
  loop seq [] 1

let rec print_int_list = function
  | [] -> Printf.printf "\n"
  | lst :: [] -> Printf.printf "%d\n" lst
  | first :: rest ->
    begin
      Printf.printf "%d " first;
      print_int_list rest
    end

let _ =
  let ans = Scanf.scanf "%d\n" solve in
  Printf.printf "%d\n" (List.length ans);
  if List.length ans != 0 then print_int_list (List.rev ans)

let rec input_seq n lst =
  if n <= 1 then (Scanf.scanf "%d\n" (fun x -> x)) :: lst
  else input_seq (n - 1) ((Scanf.scanf "%d " (fun x -> x)) :: lst)

let input_seq n = List.rev (input_seq n [])

let solve n =
  let seq = input_seq n in
  let sum = List.fold_left (+) 0 seq in
  let rec loop lst accm cnt = match lst with
    | [] -> accm
    | first :: rest
	-> if (sum-first) / (n - 1) == first then loop rest (cnt::accm) (cnt+1)
	  else loop rest accm (cnt+1)
  in
  loop seq [] 1

let rec print_int_list = function
  | [] -> Printf.printf "\n"
  | lst :: [] -> Printf.printf "%d\n" lst
  | first :: rest ->
    begin
      Printf.printf "%d " first;
      print_int_list rest
    end

let _ =
  let ans = Scanf.scanf "%d\n" solve in
  Printf.printf "%d\n" (List.length ans);
  print_int_list (List.rev ans)


let n = int_of_string (input_line stdin) ;;

let sum a b c = a + b + c ;;

let rec solve i count =
    if i == 0 then count
    else let input = Scanf.bscanf Scanf.Scanning.stdin "%d %d %d\n" sum in
      if input > 1 then solve (i - 1) (count + 1)
      else solve (i - 1) count ;;

Printf.printf "%d\n" (solve n 0) ;;

let number_of_problems = Scanf.scanf "%d " (fun n -> n)

let if_certain d = match d with
    |0 -> false
    |_-> true

let remove_uncertainity l = List.filter(if_certain) l

let rec getting_statuses n k =
    if n > 0
    then
        let status = Scanf.scanf "%d %d %d " (fun s0 s1 s2 -> [s0; s1; s2]) in
        if (List.length (remove_uncertainity status)) >= 2
        then
            getting_statuses(n - 1) (k + 1)
        else
            getting_statuses(n - 1) k
    else
        Printf.printf ("%d\n") k

let () = getting_statuses number_of_problems 0

let input () = let number_of_problems = Scanf.scanf "%d " (fun n -> n) in
    let rec getting_statuses n =
    if n > 0
    then
        let status = Scanf.scanf "%d %d %d " (fun s0 s1 s2 -> [s0; s1; s2]) in
        let rest = getting_statuses (n - 1) in
        (status :: rest)
    else
        []
    in getting_statuses number_of_problems

let if_certain d = match d with
    |0 -> false
    |_-> true

let count f l = List.length (List.filter f l)

let solve : int list list -> int = count (fun l -> count if_certain l >= 2)

let print k = Printf.printf "%d\n" k

let () = print (solve (input ()))

let rec loop n =
  if n == 0 then
    0
  else
    let score = Scanf.scanf "%d %d %d\n" (fun x y z -> if x+y+z >= 2 then 1 else 0) in
    score + loop (n-1);;

let _ =
  let n = read_int() in
  print_int(loop n) in
  print_newline()

let n=Scanf.scanf "%d" (fun a->a);;
let ans= ref 0;;
for i=1 to n do
    ans:=!ans+(Scanf.scanf " %d %d %d" (fun a b c->if a+b+c>=2 then 1 else 0))
done;;
print_int(!ans)

let n=Scanf.scanf "%d" (fun a->a);;
let ans= ref 0;;
for i=1 to n do
    let (a,b,c)=(Scanf.scanf " %d %d %d" (fun a b c->(a,b,c))) in
    if a+b+c>=2 then ans:=!ans+1
done;;
print_int(!ans)

let check lst = 2 <= List.fold_left (+) 0 lst
;;

let solve llst = List.length (List.filter check llst)
;;

let make_nums n =
  let arr = Array.init n (fun _ -> Scanf.scanf "%d %d %d "
                                               (fun n m k -> [n; m; k;]))
  in
  Array.to_list arr
;;

let () =
  let nums = Scanf.scanf "%d "
                          (fun n -> make_nums n)
  in
  Printf.printf "%d\n" (solve nums)
;;

let read_int () = Scanf.scanf "%d " (fun x -> x);;
let read_int3 () = Scanf.scanf " %d %d %d " (fun x y z -> (x,y,z) );;

let n = read_int ();;

let a = Array.init n (fun i -> (read_int3 () ));;

let vote = function
  | (0,0,0) -> 0
  | (1,0,0) -> 0
  | (0,1,0) -> 0
  | (0,0,1) -> 0
  | (_,_,_) -> 1
;;

let b = Array.map (fun x -> vote x) a
        |> Array.fold_left (+) 0
    in print_int b; print_endline ""

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

let solve n =
  let rec check_opinions acc = function
    | 0 -> acc
    | n -> let o1 = read_int ()
           and o2 = read_int ()
           and o3 = read_int () in
           if o1 + o2 + o3 > 1
           then check_opinions (acc + 1) (n - 1)
           else check_opinions acc (n - 1)
  in check_opinions 0 n

let () =
  let n = read_int () in
  Printf.printf "%d\n" (solve n)

open Scanf

let rec solve n =
  if n =  0 then 0
  else
    begin
      scanf "%d %d %d\n" (fun x y z ->
	let rest = solve (n - 1) in
	if (x = 0 && y = 0 || x = 0 && z = 0 || y = 0 && z = 0) then rest
	else 1 + rest)
    end

let _ =
  Printf.printf "%d\n" (scanf "%d\n" solve)

let read_one () = Scanf.scanf " %d" (fun x -> x)
let read_two () = Scanf.scanf " %d %d" (fun x y -> (x,y))
let read_three () = Scanf.scanf " %d %d %d" (fun x y z -> (x,y,z))

let read_many n =
  let rec helper i acc =
    if i >= n then List.rev acc
    else Scanf.scanf " %d" (fun n -> helper (i+1) (n::acc)) in
  helper 0 []

let list_iteri f lst = List.fold_left (fun j b -> f j b; j+1) 0 lst

let main =
  let t = Scanf.scanf "%d" (fun t -> t) in
  let sum = ref 0 in
  for case = 1 to t do
    let (a,b,c) = read_three() in
    sum := !sum + if a+b+c >= 2 then 1 else 0;
  done;
  Printf.printf "%d\n" !sum

let pf = Printf.printf;;
let sf = Scanf.scanf;;

let (|>) x f = f x;;
let (@@) f x = f x;;
let read0() = sf "%d " (fun x -> x)
let read1() = sf "%d\n" (fun x -> x)
let read2() = sf "%d %d\n" (fun x y -> x, y)
let read3() = sf "%d %d %d\n" (fun x y z -> x, y, z)

exception Error of string

let inf = 1000000000;;
let eps = 1e-11;;

let _ =
  let n = read1() in
  let res = ref 0 in
  for i = 1 to n do
    let (x, y, z) = read3() in
    if x + y + z >= 2 then res := !res + 1
  done;
  pf "%d\n" !res
;;

let read_int () =
  Scanf.bscanf Scanf.Scanning.stdin " %d " (fun x -> x)

let rec solve n =
  if n == 0 then 0
  else if read_int () + read_int () + read_int () > 1 then 1 + solve (n - 1)
  else 0 + solve (n - 1)

let () =
  Printf.printf "%d" (solve (read_int ()))

open Printf

let read_ints() =
	Array.map (int_of_string) (Array.of_list (Str.split (Str.regexp " +") (read_line())))

let sum xs = Array.fold_left (+) 0 xs

let main =
    let n = read_int() in
    let answer = ref 0 in
    for i = 1 to n do
        let xs = read_ints() in
        if (sum xs) >= 2 then
            answer := !answer + 1;
    done;
    printf "%d\n" !answer;;

let read1 () = Scanf.scanf "%d\n" ( fun x -> x );;
let read2 () = Scanf.scanf "%d %d\n" ( fun x y -> x, y );;
let read3 () = Scanf.scanf "%d %d %d\n" ( fun x y z -> x, y, z);;

let rec loop n a =
  if n <= 0 then a
  else
    let (x,y,z) = read3() in
    loop (n-1) ( if x+y+z >= 2 then (a+1) else a );;

let _ =
  let n = read1() in
  Printf.printf "%d\n" ( loop n 0 );;

let number_of_problems = Scanf.scanf "%d " (fun n -> n)

let if_certain d = match d with
    |0 -> false
    |_-> true

let remove_uncertainity l = List.filter(if_certain) l

let rec getting_statuses n k =
    if n > 0
    then
        let status = Scanf.scanf "%d %d %d " (fun s0 s1 s2 -> [s0; s1; s2]) in
        if (List.length (remove_uncertainity status)) >= 2
        then
            getting_statuses(n - 1) (k + 1)
        else
            ()
    else
        Printf.printf ("%d\n") k

let () = getting_statuses number_of_problems 0

open Scanf

let rec solve n =
  if n =  0 then 0
  else
    begin
      scanf "%d %d %d\n" (fun x y z ->
	let rest = solve (n - 1) in
	if x = 0 && y = 0 && z = 0 then rest
	else 1 + rest)
    end

let _ =
  Printf.printf "%d\n" (scanf "%d\n" solve)

let read_int =
  Scanf.bscanf Scanf.Scanning.stdin " %d " (fun x -> x)

let rec solve n =
  if n == 0 then 0
  else if read_int + read_int + read_int > 1 then 1 + solve (n - 1)
  else 0 + solve (n - 1)

let () =
  Printf.printf "%d" (solve read_int)


let input () = Scanf.scanf "%d " (fun n -> n)

let print_looper n a =
    let rec loop i =
        if i < n
        then
            (Printf.printf "%d " a;
            loop (i + 1))
        else
            ()
    in loop 0

let wrapper (n, a, b) =
    Printf.printf "%d\n" n;
    print_looper a 2;
    print_looper b 3;
    Printf.printf "\n"

let solve n =
    let total = n / 2 in
    let modulo = n mod 2 in
    if modulo = 1
    then
        (total, total - 1, 1)
    else
        (total, total, 0)

let () = wrapper (solve (input ()))

let main () =
  let n = read_int () in
    let k = n / 2 in
    print_int k; print_newline ();
    for i = 1 to k-1 do
      print_string "2 "
    done;
    print_int (n - 2 * (k-1))

let () = main ()

open Printf
open Scanf

let rec print2 k = if k = 0 then () else let () = print2(k-1) in printf "%d " 2

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x) in
let () =
    let n = read_int() in
    let () = printf "%d\n" (n/2) in
    if n mod 2 = 0 then
        print2 (n/2)
    else let () = print2 (n/2-1) in printf "%d" 3 in
()

open Printf
open Scanf

(* int -> int list
   create_range(n) = [2,..., k-1] len = k-2
 *)
let rec create_range k = if k <= 2 then [] else
                        List.append (create_range (k-1)) [k-1] in

(* int -> bool
   true iff n is a prime
 *)
let isPrime n = if n < 2 then false else
                if n == 2 then true else
                let divisible k = if (n mod k) = 0 then true else false in
                let range = create_range n in
                not (List.exists divisible range) in

(* int -> int list
   length(res) = n-1 and res[i] = answer for i+2 *)

let rec produce_table n range primes = if n = 2 then [1] else
                      let res_table = produce_table (n-1) primes range in
                      let fold_help prime res = if n-prime < 2 then res else
                                                let index = n-prime-2 in
                                                let pot = List.nth res_table index in
                                                if pot > res then pot else res in
                      let new_val = 1 + List.fold_right fold_help primes 0 in
                      List.append res_table [new_val] in

(* int -> int list
   returns a list of primes
   *)

let rec produce_primes n res_table range primes = if n = 2 then [2] else
                       let help a = let fst = List.nth res_table (a-2) in
                                    let snd = List.nth res_table (n-2) in
                                    if snd = fst + 1 then true else false in
                        let fold_help a b = if n-a > 2 && help (n-a) then
                                            [a] else b in
                        let index = List.fold_right fold_help primes [] in
                        match index with
                              [prime] -> prime::(produce_primes (n-prime) res_table range primes)
                            |  _ -> [n] in

(* processing input *)

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x) in
let () =
    let n = read_int() in
    let range = create_range(n) in
    let primes = List.filter isPrime range in
    let res_table = produce_table n range primes in
    let answer = produce_primes n res_table range primes in
    let len = List.length answer in
    let () = printf "%d\n" len in
    let helpero a = printf "%d " a in
    List.iter helpero answer in
()


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

let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let a = Array.make n Int64.zero in
  let res = ref Int64.zero in
  let ones = ref Int64.zero in
  for i = 0 to n-1 do
    let m = Scanf.scanf "%Ld " (fun x -> x) in
    let m2 = m / 2L in
    let x = min (m / 2L) !ones in
    res := !res + x;
    ones := !ones -- x;
    let m = m -- x * 2L in
    a.(i) <- m;
    let m3 = m / 3L in
    res := !res + m3;
    ones := !ones + m -- m3 * 3L;
  done;
  Printf.printf "%Ld" !res
;;

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

let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let a = Array.make n Int64.zero in
  let res = ref Int64.zero in
  let ones = ref Int64.zero in
  for i = 0 to n-1 do
    let m = Scanf.scanf "%Ld " (fun x -> x) in
    let m2 = m / (Int64.of_int 2) in
    let x = min (m / (Int64.of_int 2)) !ones in
    res := !res + x;
    ones := !ones -- x;
    let m = m -- x * Int64.of_int 2 in
    a.(i) <- m;
    let m3 = m / (Int64.of_int 3) in
    res := !res + m3;
    ones := !ones + m -- m3 * (Int64.of_int 3);
  done;
  Printf.printf "%Ld" !res
;;

let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let a = Array.make n 0 in
  let res = ref 0 in
  let ones = ref 0 in
  for i = 0 to n-1 do
    let m = Scanf.scanf "%d " (fun x -> x) in
    let m2 = m / 2 in
    let x = min (m / 2) !ones in
    res := !res + x;
    ones := !ones - x;
    let m = m - x * 2 in
    let m3 = m / 3 in
    res := !res + m3;
    ones := !ones + m - m3 * 3;
  done;
  Printf.printf "%d" !res
;;

let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let res = ref 0 in
  for i = 0 to n-1 do
    let m = Scanf.scanf "%d " (fun x -> x/3) in
    res := !res + m
  done;
  Printf.printf "%d" !res
;;

let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let a = Array.make n 0 in
  let res = ref 0 in
  for i = 0 to n-1 do
    let m = Scanf.scanf "%d " (fun x -> x) in
    let m3 = m / 3 in
    res := !res + m3;
    a.(i) <- m - m3 * 3;
  done;
  let ones = ref 0 in
  Array.iter (function
      | 2 when !ones > 0 -> decr ones; incr res;
      | 2 -> incr ones; incr ones;
      | 1 -> incr ones;
      | _ -> ()
    ) a;
  Printf.printf "%d" !res
;;

let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let a = Array.make n 0 in
  let res = ref 0 in
  for i = 0 to n-1 do
    let m = Scanf.scanf "%d " (fun x -> x) in
    let m3 = m / 3 in
    res := !res + m3;
    a.(i) <- m - m3;
  done;
  let ones = ref 0 in
  Array.iter (function
      | 2 when !ones > 0 -> decr ones; incr res;
      | 2 -> incr ones; incr ones;
      | 1 -> incr ones;
      | _ -> ()
    ) a;
  Printf.printf "%d" !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
module IMap = Map.Make (Int64)
let count a = (* (value,count) *)
  Array.fold_left (fun u v -> IMap.add v (1L + try IMap.find v u with Not_found -> 0L) u) IMap.empty a
let () =
  let n = get_i64 0 in
  let a = input_i64_array n in
  let mp = count a in
  let sum = fold_left (+) 0L a in
  let ans = ref [] in
  iteri (fun i v ->
    let rest = sum - v in
    if rest mod 2L = 0L then
    try
      let c = IMap.find (rest/2L) mp in
      if v = rest/2L then (
        if c >= 2L then ans := (i+$1) :: !ans
      ) else if c >= 1L then ans := (i+$1) :: !ans
    with Not_found -> ()
  ) a;
  printf "%Ld\n" @@ llen !ans;
  print_list string_of_int !ans

(* Problem 2 of round 521*)
open Scanf;;
open String;;
open Num;;

(*These are some utility functions*)
module U = struct
  let mprint z =
    print_endline (Num.string_of_num z);;

  let read_one format =
    let n = Scanf.scanf format (fun x -> x) in
    n;;

  let read_one_number () =
    let n = read_one "%d " in
    n

  let read_array n a =
    for i = 0 to n-1 do
      let n = read_one_number () in
      a.(i) <- n
    done

end

(*The solutions*)

let n = U.read_one_number ()
let a = Array.make n 0
let () = U.read_array n a

module H = Hashtbl
let t = H.create n

(*
let () =
  Array.iter (fun x-> print_int x; print_endline "") a
*)

open Num;;
let n1 = num_of_int 1;;

let total = ref (num_of_int 0)
let () =
  Array.iter (fun x-> H.add t (num_of_int x) (num_of_int 0)) a;
  Array.iter (fun x-> H.replace t (num_of_int x) (n1+/(H.find t (num_of_int x)))) a;
  Array.iter (fun x -> total := !total +/ (num_of_int x)) a;;

(*
print_int !total; print_endline ""
let () =
  H.iter (fun k v -> Printf.printf "%d %d\n" k v) t
*)

let my_find x =
  try H.find t x
  with Not_found -> num_of_int 0

let n0 = num_of_int 0;;

let is_good x =
  let r = !total -/ x in
  let m = int_of_num (mod_num r (num_of_int 2)) in
  match m with
    1 -> false
  | _ -> begin
      let r1 = r // (num_of_int 2) in
      let rslt = int_of_num (my_find r1) in
      match rslt with
        0 -> false
      | 1 -> begin
          if eq_num r1 x then
            false
          else
            true
        end
      | _ -> true
    end

let s = H.create n;;

let () =
  Array.iteri (fun i x -> if (is_good (num_of_int x)) then
                  begin H.add s (num_of_int (i + 1) ) n0 end
              ) a
;;

let () =
  print_int (H.length s); print_endline "";
  H.iter (fun k v -> Printf.printf "%d " (int_of_num k)) s

(* Problem 2 of round 521*)
open Scanf;;
open String;;
open Num;;

(*These are some utility functions*)
module U = struct
  let mprint z =
    print_endline (Num.string_of_num z);;

  let read_one format =
    let n = Scanf.scanf format (fun x -> x) in
    n;;

  let read_one_number () =
    let n = read_one "%d " in
    n

  let read_array n a =
    for i = 0 to n-1 do
      let n = read_one_number () in
      a.(i) <- n
    done

end

(*The solutions*)

let n = U.read_one_number ()
let a = Array.make n 0
let () = U.read_array n a

module H = Hashtbl
let t = H.create n

(*
let () =
  Array.iter (fun x-> print_int x; print_endline "") a
*)

open Num;;
let n1 = num_of_int 1;;

let total = ref (num_of_int 0)
let () =
  Array.iter (fun x-> H.add t (num_of_int x) (num_of_int 0)) a;
  Array.iter (fun x-> H.replace t (num_of_int x) (n1+/(H.find t (num_of_int x)))) a;
  Array.iter (fun x -> total := !total +/ (num_of_int x)) a;;

(*
print_int !total; print_endline ""
let () =
  H.iter (fun k v -> Printf.printf "%d %d\n" k v) t
*)

let my_find x =
  try H.find t x
  with Not_found -> num_of_int 0

let n0 = num_of_int 0;;

let is_good x =
  let r = !total -/ x in
  let m = int_of_num (mod_num r (num_of_int 2)) in
  match m with
    1 -> false
  | _ -> begin
      let r1 = r // (num_of_int 2) in
      let rslt = int_of_num (my_find r1) in
      match rslt with
        0 -> false
      | 1 -> begin
          if r1 == x then
            false
          else
            true
        end
      | _ -> true
    end

let s = H.create n;;

let () =
  Array.iteri (fun i x -> if (is_good (num_of_int x)) then
                  begin H.add s (num_of_int (i + 1) ) n0 end
              ) a
;;

let () =
  print_int (H.length s); print_endline "";
  H.iter (fun k v -> Printf.printf "%d " (int_of_num k)) s

(* Problem 2 of round 521*)
open Scanf;;
open String;;
open Num;;

(*These are some utility functions*)
module U = struct
  let mprint z =
    print_endline (Num.string_of_num z);;

  let read_one format =
    let n = Scanf.scanf format (fun x -> x) in
    n;;

  let read_one_number () =
    let n = read_one "%d " in
    n

  let read_array n a =
    for i = 0 to n-1 do
      let n = read_one_number () in
      a.(i) <- n
    done

end

(*The solutions*)

let n = U.read_one_number ()
let a = Array.make n 0
let () = U.read_array n a

module H = Hashtbl
let t = H.create n

(*
let () =
  Array.iter (fun x-> print_int x; print_endline "") a
*)

let total = ref 0
let () =
  Array.iter (fun x-> H.add t x 0) a;
  Array.iter (fun x-> H.replace t x (1+(H.find t x))) a;
  Array.iter (fun x -> total := !total + x) a;;

(*
print_int !total; print_endline ""
let () =
  H.iter (fun k v -> Printf.printf "%d %d\n" k v) t
*)

let my_find x =
  try H.find t x
  with Not_found -> 0

let is_good x =
  let r = !total -x in
  match r mod 2 with
    1 -> false
  | _ -> begin
      let r1 = r / 2 in
      let rslt = my_find r1 in
      match rslt with
        0 -> false
      | 1 -> begin
          if r1 == x then
            false
          else
            true
        end
      | _ -> true
    end

let s = H.create n;;

let () =
  Array.iteri (fun i x -> if (is_good x) then
                  begin H.add s (i+1) 0 end
              ) a
;;

let () =
  print_int (H.length s); print_endline "";
  H.iter (fun k v -> Printf.printf "%d " k) s

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

module CumulSumArray = struct
  let make a =
    let ln = Array.length a
    in let a1 = Array.make (ln+$1) 0L in for i=1 to ln do a1.(i) <- a1.(i-$1) + a.(i-$1) done; a1
  let sum l r a = (* 0-origin,closed *)
    if l>r then 0L else (a.(r+$1) - a.(l))
  let sum_1orig l r a = sum (l-$1) (r-$1) a
end
let () =
  let n = get_i64 0 in
  let a = input_i64_array n in
  let b = init (i32 n) (fun i -> a.(i)) in
  sort compare b;
  (* let c = CumulSumArray.make a in *)
  let s = fold_left (+) 0L a in
  let r = ref [] in
  repi 0 (i32 n-$1) (fun i ->
    (* let rest = CumulSumArray.sum i 0 in *)
    let rest = s - a.(i) in
    let j = lower_bound b (rest/2L) in
    (* printf "%Ld, %Ld\n" rest j; *)
    if 0L<=j && j<n && b.(i32 j)*2L = rest then (
      r := (i+$1)::!r
    )
  );
  printf "%Ld\n" @@ llen !r;
  print_list string_of_int !r


open Printf
open Scanf
let read_int _ = bscanf Scanning.stdib " %d " (fun x -> x)

let () =
    let n = read_int () and k = read_int () in
    let a = Array.init n read_int
    and h = Array.make 200001 0
    and min_elem = ref 200001
    and max_elem = ref 0
    and cnt = ref 0
    and cur = ref 0
    and ans = ref 0 in
    Array.iter (fun x ->
        min_elem := min !min_elem x;
        max_elem := max !max_elem x;
        h.(x) <- h.(x) + 1
    ) a;
    for i = !max_elem downto !min_elem + 1 do
        cnt := !cnt + h.(i);
        cur := !cur + !cnt;
        if !cur > k then begin
            incr ans;
            cur := !cnt
        end
    done;
    if max_elem <> min_elem then incr ans;
    printf "%d\n" !ans

open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) 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 abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (%$) = (mod) let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q 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 labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| 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 print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" 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 (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline 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) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

module Imos = struct
	let make n = Array.make (i32 n +$ 2) 0L
	let add_destructive_closed l r a =
		a.(l+$1) <- a.(l+$1) + 1L;
		a.(r+$2) <- a.(r+$2) - 1L
	let add_destructive_1orig_closed l r a =
		a.(l) <- a.(l) + 1L;
		a.(r+$1) <- a.(r+$1) - 1L
	let cumulate_destructive a = for i=1 to Array.length a -$ 2 do
		a.(i) <- a.(i) + a.(i-$1)
	done
end

(* let a = Array.make 200000 0L *)
let a = Imos.make 2000010L
let () =
	let n,k = get_2_i64 0 in
	let mi,mx = ref Int64.max_int,ref 0L in
	rep 1L n (fun _ ->
		let h = get_i64 0 in
		mi := min h !mi;
		mx := max h !mx;
		Imos.add_destructive_1orig_closed 1 (i32 h) a;
		`Ok
	);
	Imos.cumulate_destructive a;
	let i = ref !mx in
	let s = ref 0L in
	let c = ref 0L in
	while !i > !mi do
		(* printf "%2Ld >= %2Ld: %Ld, %Ld :: %Ld\n" !i !mi !s a.(i32 !i) !c; *)
		s += a.(i32 !i);
		if !s > k then (
			c += 1L;
			s := a.(i32 !i)
		);
		i -= 1L;
	done;
	if !s > 0L then (
		c += 1L;
	);
	(* printf "%Ld %Ld\n" !s !c; *)
	!c |> printf "%Ld\n";
	(* printf "[%Ld %Ld]: %Ld\n" !mi !mx !c; *)

let scan_int () = Scanf.scanf " %d" (fun x -> x);;
let scan_string () = Scanf.scanf " %s" (fun x -> x);;
let psp () = print_string " ";;
let b2i x = if x == true then 1 else 0;;

let n = scan_int() and k = scan_int();;
let h = Array.make n 0 ;;

for i = 0 to n - 1 do
  h.(i) <- scan_int();
done;;

Array.sort compare h;;

let ans = ref 0 and magazyn = ref 0;;

for i = n - 1 downto 1 do
  let lewy =  h.(i - 1) in
  let linia = n - i in
  let odejm = (k - !magazyn) / linia in
  let roz = h.(i) - lewy in
  if odejm <= roz && roz <> 0 then begin
    let wys = k / linia in
    let ile = (roz - if(!magazyn > 0) then odejm else 0) / wys in
    (*print_int(i); psp(); print_int(ile); psp(); print_int(!magazyn); print_newline();*)
    ans := !ans + ile + b2i(!magazyn <> 0);
    magazyn := ((roz - odejm) mod wys) * linia;
  end
  else magazyn := !magazyn + linia * roz;
  (*print_int(!magazyn); print_newline(); *)
done;;

print_int (!ans + b2i(!magazyn <> 0));;

(*
3 3
1 2 3
*)

open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) 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 abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (%$) = (mod) let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q 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 labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| 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 print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" 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 (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline 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) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

module Imos = struct
	let make n = Array.make (i32 n +$ 2) 0L
	let add_destructive_closed l r a =
		a.(l+$1) <- a.(l+$1) + 1L;
		a.(r+$2) <- a.(r+$2) - 1L
	let add_destructive_1orig_closed l r a =
		a.(l) <- a.(l) + 1L;
		a.(r+$1) <- a.(r+$1) - 1L
	let cumulate_destructive a = for i=1 to Array.length a -$ 2 do
		a.(i) <- a.(i) + a.(i-$1)
	done
end

(* let a = Array.make 200000 0L *)
let a = Imos.make 2000010L
let () =
	let n,k = get_2_i64 0 in
	let mi,mx = ref Int64.max_int,ref 0L in
	rep 1L n (fun _ ->
		let h = get_i64 0 in
		mi := min h !mi;
		mx := max h !mx;
		Imos.add_destructive_1orig_closed 1 (i32 h) a;
		`Ok
	);
	Imos.cumulate_destructive a;
	let i = ref !mx in
	let s = ref 0L in
	let c = ref 0L in
	while !i >= !mi do
		(* printf "%Ld >= %Ld: %Ld, %Ld :: %Ld\n" !i !mi !s a.(i32 !i) !c; *)
		s += a.(i32 !i);
		if !s > k then (
			c += 1L;
			s := a.(i32 !i)
		);
		i -= 1L;
	done;
	!c |> printf "%Ld\n";
	(* printf "[%Ld %Ld]: %Ld\n" !mi !mx !c; *)

let scan_int () = Scanf.scanf " %d" (fun x -> x);;
let scan_string () = Scanf.scanf " %s" (fun x -> x);;
let psp () = print_string " ";;
let b2i x = if x == true then 1 else 0;;

let n = scan_int() and k = scan_int();;
let h = Array.make n 0 ;;

for i = 0 to n - 1 do
  h.(i) <- scan_int();
done;;

Array.sort compare h;;

let ans = ref 0 and magazyn = ref 0;;

for i = n - 1 downto 1 do
  let lewy =  h.(i - 1) in
  let linia = n - i in
  let odejm = (k - !magazyn) / linia in
  let roz = h.(i) - lewy in
  if odejm <= roz && roz <> 0 then begin
    let wys = k / linia in
    let ile = (roz - odejm) / wys in
    (* print_int(ile); psp(); print_int(!magazyn); print_newline(); *)
    ans := !ans + ile + b2i(!magazyn <> 0);
    magazyn := ((roz - odejm) mod wys) * linia;
  end
  else magazyn := !magazyn + linia * roz;
  (*print_int(!magazyn); print_newline(); *)
done;;

print_int (!ans + b2i(!magazyn <> 0));;


let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)

let () =
  let rf () = float (read_int()) in
  let y1 = rf() in
  let y2 = rf() in
  let yw = rf() in
  let xb = rf() in
  let yb = rf() in
  let r = rf() in

  let yb' = (yw-.r) +. (yw-.r-.yb) in
  (* reflected ball y coordinate *)

  let sq x = x*.x in

  let a = xb in
  let yh = r +. y1 in
  let b = yb' -. yh in
  let c = sqrt ((sq a) +. (sq b)) in
  let h = (c/.a) *. r in
  let yt = yh +. h in
    if yt >= y2 then Printf.printf "-1\n"
    else (
      (* we aim at position yh *)
      let d = xb in
      let c = yb' -. yh in
      let b = yb' -. (yw -. r) in
      let a = (d/.c) *. b in
      let xw1 = xb -. a in

(*	if yb -. r >= y1 then Printf.printf "%.10f\n" xw1 *)
	if true then Printf.printf "%.10f\n" xw1
	else (
	  let c = sqrt ((sq xb) +. (sq (y1 -. yb))) in
	  let alpha = asin (r/.c) in
	  let beta = asin ((y1 -. yb)/.c) in
	  let phi = alpha +. beta in
	  let xw2 = xb -. ((yw -. r -. yb) /. (tan phi)) in
	    if xw2 > xw1 then Printf.printf "-1\n" else Printf.printf "%.10f\n" xw1
	)
    )

(* Codeforces 248C Football Robot Electronic *)

open Big_int;;
open List;;

(* you can use either gr or rdln but not both *)
let gr () = Scanf.scanf " %d" (fun i -> i);;
let grf () = Scanf.scanf " %f" (fun i -> i);;
let grl () = Scanf.scanf " %Ld" (fun i -> i);;
let rdln() = input_line stdin;;
(* let spli s = Str.split (Str.regexp " ") s;; *)
let printlisti li = List.iter (fun i -> (print_int i; print_string " ")) li;;
let printarri ai = Array.iter (fun i -> (print_int i; print_string " ")) ai;;
let debug = false;;

let main () =
	let y1 = grf() in
	let y2 = grf() in
	let yw = grf() in
	let xb = grf() in
	let yb = grf() in
	let r = grf() in
	begin
		if debug then begin
  		print_string "y1,y2,yw,xb,yb,r=";
  		print_float y1; print_string " ";
  		print_float y2; print_string " ";
  		print_float yw; print_string " ";
  		print_float xb; print_string " ";
  		print_float yb; print_string " ";
  		print_float r; print_string " done print input\n"
		end;
	let targ = (y2 +. y1) *. 0.5 in
	let dy2 = yw -. r -. yb in
	let dy1 = yw -. r -. r -. y1 in
	let dy = dy1 +. dy2 in
	let al = atan (xb /. dy) in
	let xw = xb *. dy1 /. dy in
	let halfg = y2 -. y1 -. r in
	let rr = halfg *. (sin al) in
	begin
		if debug then begin
  		print_string "targ dy2 dy1 dy al xw halfg rr =";
  		print_float targ; print_string " ";
  		print_float dy2; print_string " ";
  		print_float dy1; print_string " ";
  		print_float dy; print_string " ";
  		print_float al; print_string " ";
  		print_float xw; print_string " ";
  		print_float halfg; print_string " ";
  		print_float rr; print_string " done print vars\n"
		end;
	let retv =
		(if rr < r then -1.0
		 else if rr > r *. 1.01 then xw -. 0.0001
		 else xw)
		in
	print_float retv
	end end;;

main();;

let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)

let () =
  let rf () = float (read_int()) in
  let y1 = rf() in
  let y2 = rf() in
  let yw = rf() in
  let xb = rf() in
  let yb = rf() in
  let r = rf() in

  let yb' = (yw-.r) +. (yw-.r-.yb) in
  (* reflected ball y coordinate *)

  let sq x = x*.x in

  let a = xb in
  let yh = r +. y1 in
  let b = yb' -. yh in
  let c = sqrt ((sq a) +. (sq b)) in
  let h = (c/.a) *. r in
  let yt = yh +. h in
    if yt >= y2 then Printf.printf "-1\n"
    else (
      (* we aim at position yh *)
      let d = xb in
      let c = yb' -. yh in
      let b = yb' -. (yw -. r) in
      let a = (d/.c) *. b in
      let xw1 = xb -. a in

	if yb -. r >= y1 then Printf.printf "%.10f\n" xw1
	else (
	  let c = sqrt ((sq xb) +. (sq (y1 -. yb))) in
	  let alpha = asin (r/.c) in
	  let beta = asin ((y1 -. yb)/.c) in
	  let phi = alpha +. beta in
	  let xw2 = xb -. ((yw -. r -. yb) /. (tan phi)) in
	    if xw2 > xw1 then Printf.printf "-1\n" else Printf.printf "%.10f\n" xw1
	)
    )

(* Codeforces 248C Football Robot Electronic *)

open Big_int;;
open List;;

(* you can use either gr or rdln but not both *)
let gr () = Scanf.scanf " %d" (fun i -> i);;
let grf () = Scanf.scanf " %f" (fun i -> i);;
let grl () = Scanf.scanf " %Ld" (fun i -> i);;
let rdln() = input_line stdin;;
(* let spli s = Str.split (Str.regexp " ") s;; *)
let printlisti li = List.iter (fun i -> (print_int i; print_string " ")) li;;
let printarri ai = Array.iter (fun i -> (print_int i; print_string " ")) ai;;
let debug = false;;

let main () =
	let y1 = grf() in
	let y2 = grf() in
	let yw = grf() in
	let xb = grf() in
	let yb = grf() in
	let r = grf() in
	begin
		if debug then begin
  		print_string "y1,y2,yw,xb,yb,r=";
  		print_float y1; print_string " ";
  		print_float y2; print_string " ";
  		print_float yw; print_string " ";
  		print_float xb; print_string " ";
  		print_float yb; print_string " ";
  		print_float r; print_string " done print input\n"
		end;
	let targ = (y2 +. y1) *. 0.5 in
	let dy2 = yw -. r -. yb in
	let dy1 = yw -. r -. r -. y1 in
	let dy = dy1 +. dy2 in
	let al = atan (xb /. dy) in
	let xw = xb *. dy1 /. dy in
	let halfg = y2 -. y1 -. r in
	let rr = halfg *. (sin al) in
	begin
		if debug then begin
  		print_string "targ dy2 dy1 dy al xw halfg rr =";
  		print_float targ; print_string " ";
  		print_float dy2; print_string " ";
  		print_float dy1; print_string " ";
  		print_float dy; print_string " ";
  		print_float al; print_string " ";
  		print_float xw; print_string " ";
  		print_float halfg; print_string " ";
  		print_float rr; print_string " done print vars\n"
		end;
	let retv =
		(if rr < r then -1.0
		 else if rr > r *. 1.01 then xw +. 0.0001
		 else xw)
		in
	print_float retv
	end end;;

main();;

(* Codeforces 248C Football Robot Electronic *)

open Big_int;;
open List;;

(* you can use either gr or rdln but not both *)
let gr () = Scanf.scanf " %d" (fun i -> i);;
let grf () = Scanf.scanf " %f" (fun i -> i);;
let grl () = Scanf.scanf " %Ld" (fun i -> i);;
let rdln() = input_line stdin;;
(* let spli s = Str.split (Str.regexp " ") s;; *)
let printlisti li = List.iter (fun i -> (print_int i; print_string " ")) li;;
let printarri ai = Array.iter (fun i -> (print_int i; print_string " ")) ai;;
let debug = false;;

let main () =
	let y1 = grf() in
	let y2 = grf() in
	let yw = grf() in
	let xb = grf() in
	let yb = grf() in
	let r = grf() in
	begin
		if debug then begin
  		print_string "y1,y2,yw,xb,yb,r=";
  		print_float y1; print_string " ";
  		print_float y2; print_string " ";
  		print_float yw; print_string " ";
  		print_float xb; print_string " ";
  		print_float yb; print_string " ";
  		print_float r; print_string " done print input\n"
		end;
	let targ = (y2 +. y1) *. 0.5 in
	let dy2 = yw -. r -. yb in
	let dy1 = yw -. r -. targ in
	let dy = dy1 +. dy2 in
	let al = atan (xb /. dy) in
	let xw = xb *. dy1 /. dy in
	let halfg = (y2 -. y1) *. 0.5 in
	begin
		if debug then begin
  		print_string "targ dy2 dy1 dy al xw halfg =";
  		print_float targ; print_string " ";
  		print_float dy2; print_string " ";
  		print_float dy1; print_string " ";
  		print_float dy; print_string " ";
  		print_float al; print_string " ";
  		print_float xw; print_string " ";
  		print_float halfg; print_string " done print vars\n"
		end;
	let retv =
		(if halfg *. (sin al) < r then -1.0
		                          else xw)
		in
	print_float retv
	end end;;

main();;

(* Codeforces 248C Football Robot Electronic *)

open Big_int;;
open List;;

(* you can use either gr or rdln but not both *)
let gr () = Scanf.scanf " %d" (fun i -> i);;
let grf () = Scanf.scanf " %f" (fun i -> i);;
let grl () = Scanf.scanf " %Ld" (fun i -> i);;
let rdln() = input_line stdin;;
(* let spli s = Str.split (Str.regexp " ") s;; *)
let printlisti li = List.iter (fun i -> (print_int i; print_string " ")) li;;
let printarri ai = Array.iter (fun i -> (print_int i; print_string " ")) ai;;
let debug = false;;

let main () =
	let y1 = grf() in
	let y2 = grf() in
	let yw = grf() in
	let xb = grf() in
	let yb = grf() in
	let r = grf() in
	begin
		if debug then begin
  		print_string "y1,y2,yw,xb,yb,r=";
  		print_float y1; print_string " ";
  		print_float y2; print_string " ";
  		print_float yw; print_string " ";
  		print_float xb; print_string " ";
  		print_float yb; print_string " ";
  		print_float r; print_string " done print input\n"
		end;
	let targ = (y2 +. y1) *. 0.5 in
	let dy2 = yw -. r -. yb in
	let dy1 = yw -. r -. r -. y1 in
	let dy = dy1 +. dy2 in
	let al = atan (xb /. dy) in
	let xw = xb *. dy1 /. dy in
	let halfg = y2 -. y1 -. r in
	let rr = halfg *. (sin al) in
	begin
		if debug then begin
  		print_string "targ dy2 dy1 dy al xw halfg rr =";
  		print_float targ; print_string " ";
  		print_float dy2; print_string " ";
  		print_float dy1; print_string " ";
  		print_float dy; print_string " ";
  		print_float al; print_string " ";
  		print_float xw; print_string " ";
  		print_float halfg; print_string " ";
  		print_float rr; print_string " done print vars\n"
		end;
	let retv =
		(if rr < r then -1.0
		                          else xw)
		in
	print_float retv
	end end;;

main();;

let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x)

let () =
  let rf () = float (read_int()) in
  let y1 = rf() in
  let y2 = rf() in
  let yw = rf() in
  let xb = rf() in
  let yb = rf() in
  let r = rf() in

  let yb = (yw-.r) +. (yw-.r-.yb) in
  (* reflected ball y coordinate *)

  let a = xb in
  let b = yb -. y1 in
  let c = sqrt (a*.a +. b*.b) in
  let h = (c/.a) *. r in
  let yh = r +. y1 in
  let yt = yh +. h in

    if yt >= y2 then Printf.printf "-1\n"
    else (
      (* we aim at position yh *)
      let d = xb in
      let c = yb -. yh in
      let b = yb -. (yw -. r) in
      let a = (d/.c) *. b in
      let xw = xb -. a in
	Printf.printf "%.10f\n" xw
    )