<?

class DllItem{
	protected $val = null;
	protected $next = null;
	protected $prev = null;

	function __construct($val){
		$this->val = $val;
	}

	function setNext(DllItem $next){
		$this->next = $next;
	}

	function setPrev(DllItem $prev){
		$this->prev = $prev;
	}

	function getNext(){
		return $this->next;
	}

	function getPrev(){
		return $this->prev;
	}

	function getValue(){
		return $this->val;
	}

	function deleteNext(){
		$this->next = null;
	}

	function deletePrev(){
		$this->prev = null;
	}

}

class DLL{
	protected $head = null;
	protected $tail = null;
	//protected $key = null;
	protected $current = null;

	protected function getCurrentNode(){
		return $this->current;
	}

	public function current(){
		return $this->current;
	}

	public function valid(){
		return !is_null($this->current);
	}

	public function next(){
		if($this->valid()){
			$this->current = $this->current->getNext();
		}
	}
	public function prev(){
		if($this->valid()){
			$this->current = $this->current->getPrev();
		}
	}

	public function rewind(){
		$this->current = $this->head;
	}

	public function append($value){
		$item = new DllItem($value);
		if (is_null($this->head)){
			$this->head = $item;
			$this->tail = $item;
			$this->current = $item;
		}else{
			$item->setPrev($this->tail);
			$this->tail->setNext($item);
			$this->tail = $item;
			$this->current = $item;
		}
	}

	public function appendLeft($value){
		$item = new DllItem($value);
		if (is_null($this->head)){
			$this->head = $item;
			$this->tail = $item;
			$this->current = $item;
		}else{
			$item->setNext($this->head);
			$this->head->setPrev($item);
			$this->head = $item;
			$this->current = $item;
		}
	}

	public function insert($value){
		if ($this->current!=$this->tail){
			$item = new DllItem($value);
			$next = $this->current->getNext();
			$next->setPrev($item);
			$item->setNext($next);
			$this->current->setNext($item);
			$this->current = $item;
		}else{
			$this->append($value);
		}
	}

	public function pop(){
		if(!is_null($this->tail)){
			$tail = $this->tail;
			$prev = $tail->getPrev();
			if(!is_null($prev)){
				$prev->deleteNext();
				$this->tail = $prev;
			}else{
				$this->tail = null;
				$this->head = null;
				$this->current = null;
			}
			return $tail->getValue();
		}else{
			//exception
		}
	}

	public function popLeft(){
		if(!is_null($this->head)){
			$head = $this->head;
			$next = $head->getNext();
			if(!is_null($next)){
				$next->deletePrev();
				$this->head = $next;
			}else{
				$this->tail = null;
				$this->head = null;
				$this->current = null;
			}
			return $head->getValue();
		}else{
			//exception
		}
	}

	public function delete(){
		if($this->valid()){
			$cur = $this->current;
			$next = $cur->getNext();
			$prev = $cur->getPrev();

			if(!is_null($next)&&!is_null($prev)){
				$next->setPrev($prev);
				$prev->setNext($next);
				$this->current = $next;

			}elseif(!is_null($prev)&&is_null($next)){
				$this->pop();
				$this->current = $prev;
			}elseif(!is_null($next)&&is_null($prev)){
				$this->popLeft();
				$this->current = $next;
			}else{
				$this->pop();
			}
		}
	}

	public function print(){
		$cur = $this->head;
		if(!is_null($cur)){
			echo " ".$cur->getValue()." ";
			while(!is_null($cur->getNext())){

				$cur = $cur->getNext();
				echo " ".$cur->getValue()." ";
			}
		}
		echo "\n";
	}

}

$dll = new DLL();

$sarr = str_split(trim(fgets(STDIN)));
foreach($sarr as $char){
	$dll->append($char);
}
$dll->rewind();

function canPlay(&$dll){
	//echo $dll->count()." cnt \n";
	//print_r($dll);
	$iter_n = 1;
	if(!$dll->valid()){
		$dll->rewind();
	}
	while ($dll->valid()){
		//echo "!";
		//Print current node's value
		$cur = $dll->current();
		$next = $cur->getNext();
		if(!is_null($next)){

			if($cur->getValue()==$next->getValue()){
				$dll->delete();
				$dll->delete();
				if($dll->valid()&&!is_null($dll->current()->getPrev())){
					$dll->prev();
				}
				return true;
			}
		}
		//Turn the cursor to next node
		$dll->next();
		/*
		if(!$dll->valid()&&$iter_n>0){
			$dll->rewind();
			$iter_n--;
		}*/

	}
	return false;
}

$res = 2;
while(true){
	$cp = canPlay($dll);
	//echo "cp ".$cp."\n";
	if($cp==true){
		if($res==2){
			$res=1;
		}else{
			$res=2;
		}
	}else{
		break;
	}
}

if($res==1){
	echo "Yes";
}else{
	echo "No";
}

<?
$sarr = str_split(trim(fgets(STDIN)));
$dll = new SplDoublyLinkedList();
foreach($sarr as $char){
	$dll->push($char);
}

function canPlay(&$dll){
	if($dll->count()<2){
		return false;
	}
	while ($dll->valid()){
		//Print current node's value
		$cur = $dll->current();
		if($dll->offsetExists($dll->key()+1)){

			$next = $dll->offsetGet($dll->key()+1);
			echo $dll->current()."\n";
			if ($next == $cur){
				$dll->offsetUnset($dll->key());
				$dll->offsetUnset($dll->key());
				$dll->rewind();
				return true;
			}
		}
		//Turn the cursor to next node
		$dll->next();
	}
	return false;
}

$res = 2;
while(canPlay($dll)){
	if($res==2){
		$res=1;
	}else{
		$res=2;
	}
}

if($res==1){
	echo "Yes";
}else{
	echo "No";
}

<?

class DllItem{
	protected $val = null;
	protected $next = null;
	protected $prev = null;

	function __construct($val){
		$this->val = $val;
	}

	function setNext(DllItem $next){
		$this->next = $next;
	}

	function setPrev(DllItem $prev){
		$this->prev = $prev;
	}

	function getNext(){
		return $this->next;
	}

	function getPrev(){
		return $this->prev;
	}

	function getValue(){
		return $this->val;
	}

	function deleteNext(){
		$this->next = null;
	}

	function deletePrev(){
		$this->prev = null;
	}

}

class DLL{
	protected $head = null;
	protected $tail = null;
	//protected $key = null;
	protected $current = null;

	protected function getCurrentNode(){
		return $this->current;
	}

	public function current(){
		return $this->current;
	}

	public function valid(){
		return !is_null($this->current);
	}

	public function next(){
		if($this->valid()){
			$this->current = $this->current->getNext();
		}
	}

	public function rewind(){
		$this->current = $this->head;
	}

	public function append($value){
		$item = new DllItem($value);
		if (is_null($this->head)){
			$this->head = $item;
			$this->tail = $item;
			$this->current = $item;
		}else{
			$item->setPrev($this->tail);
			$this->tail->setNext($item);
			$this->tail = $item;
			$this->current = $item;
		}
	}

	public function appendLeft($value){
		$item = new DllItem($value);
		if (is_null($this->head)){
			$this->head = $item;
			$this->tail = $item;
			$this->current = $item;
		}else{
			$item->setNext($this->head);
			$this->head->setPrev($item);
			$this->head = $item;
			$this->current = $item;
		}
	}

	public function insert($value){
		if ($this->current!=$this->tail){
			$item = new DllItem($value);
			$next = $this->current->getNext();
			$next->setPrev($item);
			$item->setNext($next);
			$this->current->setNext($item);
			$this->current = $item;
		}else{
			$this->append($value);
		}
	}

	public function pop(){
		if(!is_null($this->tail)){
			$tail = $this->tail;
			$prev = $tail->getPrev();
			if(!is_null($prev)){
				$prev->deleteNext();
				$this->tail = $prev;
			}else{
				$this->tail = null;
				$this->head = null;
				$this->current = null;
			}
			return $tail->getValue();
		}else{
			//exception
		}
	}

	public function popLeft(){
		if(!is_null($this->head)){
			$head = $this->head;
			$next = $head->getNext();
			if(!is_null($next)){
				$next->deletePrev();
				$this->head = $next;
			}else{
				$this->tail = null;
				$this->head = null;
				$this->current = null;
			}
			return $head->getValue();
		}else{
			//exception
		}
	}

	public function delete(){
		if($this->valid()){
			$cur = $this->current;
			$next = $cur->getNext();
			$prev = $cur->getPrev();

			if(!is_null($next)&&!is_null($prev)){
				$next->setPrev($prev);
				$prev->setNext($next);
				$this->current = $next;

			}elseif(!is_null($prev)&&is_null($next)){
				$this->pop();
				$this->current = $prev;
			}elseif(!is_null($next)&&is_null($prev)){
				$this->popLeft();
				$this->current = $next;
			}else{
				$this->pop();
			}
		}
	}

	public function print(){
		$cur = $this->head;
		if(!is_null($cur)){
			echo " ".$cur->getValue()." ";
			while(!is_null($cur->getNext())){

				$cur = $cur->getNext();
				echo " ".$cur->getValue()." ";
			}
		}
		echo "\n";
	}

}

$dll = new DLL();

$sarr = str_split(trim(fgets(STDIN)));
foreach($sarr as $char){
	$dll->append($char);
}
$dll->rewind();

function canPlay(&$dll){
	//echo $dll->count()." cnt \n";
	//print_r($dll);
	$iter_n = 1;
	if(!$dll->valid()){
		$dll->rewind();
	}
	while ($dll->valid()){
		//echo "!";
		//Print current node's value
		$cur = $dll->current();
		$next = $cur->getNext();
		if(!is_null($next)){

			if($cur->getValue()==$next->getValue()){
				$dll->delete();
				$dll->delete();
				return true;
			}
		}
		//Turn the cursor to next node
		$dll->next();
		/*
		if(!$dll->valid()&&$iter_n>0){
			$dll->rewind();
			$iter_n--;
		}*/

	}
	return false;
}

$res = 2;
while(true){
	$cp = canPlay($dll);
	//echo "cp ".$cp."\n";
	if($cp==true){
		if($res==2){
			$res=1;
		}else{
			$res=2;
		}
	}else{
		break;
	}
}

if($res==1){
	echo "Yes";
}else{
	echo "No";
}

<?

$sarr = str_split(trim(fgets(STDIN)));
$dll = new SplDoublyLinkedList();
foreach($sarr as $char){
	$dll->push($char);
}
$dll->rewind();
//print_r($dll);

function canPlay(&$dll){
	//echo $dll->count()." cnt \n";
	//print_r($dll);
	$iter_n = 1;
	while ($dll->valid()){
		//echo "!";
		//Print current node's value
		$cur = $dll->current();
		//echo $cur."\n";
		if($dll->offsetExists($dll->key()+1)){

			$next = $dll->offsetGet($dll->key()+1);
			//echo $dll->current()."\n";
			if ($next == $cur){
				$dll->offsetUnset($dll->key());
				$dll->offsetUnset($dll->key());
				//print_r($dll);
				if ($iter_n <=1 ) {
					$iter_n++;

				}

				return true;
			}
		}
		//Turn the cursor to next node
		$dll->next();
		if(!$dll->valid()&&$iter_n>=0){
			$dll->rewind();
			$iter_n--;
		}

	}
	return false;
}

$res = 2;
while(true){
	$cp = canPlay($dll);
	if($cp){
		if($res==2){
			$res=1;
		}else{
			$res=2;
		}
	}else{
		break;
	}
}

if($res==1){
	echo "Yes";
}else{
	echo "No";
}

<?
$sarr = str_split(trim(fgets(STDIN)));
$dll = new SplDoublyLinkedList();
foreach($sarr as $char){
	$dll->push($char);
}

print_r($dll);

function canPlay(&$dll){
	if($dll->count()<2){
		return false;
	}
	while ($dll->valid()){
		//Print current node's value
		$cur = $dll->current();
		if($dll->offsetExists($dll->key()+1)){

			$next = $dll->offsetGet($dll->key()+1);
			echo $dll->current()."\n";
			if ($next == $cur){
				$dll->offsetUnset($dll->key());
				$dll->offsetUnset($dll->key());
				$dll->rewind();
				return true;
			}
		}
		//Turn the cursor to next node
		$dll->next();
	}
	return false;
}

$res = 2;
while(canPlay($dll)){
	if($res==2){
		$res=1;
	}else{
		$res=2;
	}
}

if($res==1){
	echo "Yes";
}else{
	echo "No";
}

<?

$sarr = str_split(trim(fgets(STDIN)));
$dll = new SplDoublyLinkedList();
foreach($sarr as $char){
	$dll->push($char);
}

//print_r($dll);

function canPlay(&$dll){
	//echo $dll->count()." cnt \n";
	$iter_n = 0;
	while ($dll->valid()){
		//echo "!";
		//Print current node's value
		$cur = $dll->current();
		//echo $cur."\n";
		if($dll->offsetExists($dll->key()+1)){

			$next = $dll->offsetGet($dll->key()+1);
			//echo $dll->current()."\n";
			if ($next == $cur){
				$dll->offsetUnset($dll->key());
				$dll->offsetUnset($dll->key());
				//print_r($dll);
				if ($iter_n == 0 ) {
					$iter_n = 1;

				}

				return true;
			}
		}
		//Turn the cursor to next node
		$dll->next();
		if(!$dll->valid()&&$iter_n>0){
			$dll->rewind();
		}

	}
	return false;
}

$res = 2;
while(true){
	$cp = canPlay($dll);
	if($cp){
		if($res==2){
			$res=1;
		}else{
			$res=2;
		}
	}else{
		break;
	}
}

if($res==1){
	echo "Yes";
}else{
	echo "No";
}

<?

$sarr = str_split(trim(fgets(STDIN)));
$dll = new SplDoublyLinkedList();
foreach($sarr as $char){
	$dll->push($char);
}

//print_r($dll);

function canPlay(&$dll){
	//echo $dll->count()." cnt \n";
	$iter_n = 1;
	while ($dll->valid()){
		//echo "!";
		//Print current node's value
		$cur = $dll->current();
		//echo $cur."\n";
		if($dll->offsetExists($dll->key()+1)){

			$next = $dll->offsetGet($dll->key()+1);
			//echo $dll->current()."\n";
			if ($next == $cur){
				$dll->offsetUnset($dll->key());
				$dll->offsetUnset($dll->key());
				//print_r($dll);
				if ($iter_n <=1 ) {
					$iter_n++;

				}

				return true;
			}
		}
		//Turn the cursor to next node
		$dll->next();
		if(!$dll->valid()&&$iter_n>0){
			$dll->rewind();
			$iter_n--;
		}

	}
	return false;
}

$res = 2;
while(true){
	$cp = canPlay($dll);
	if($cp){
		if($res==2){
			$res=1;
		}else{
			$res=2;
		}
	}else{
		break;
	}
}

if($res==1){
	echo "Yes";
}else{
	echo "No";
}


<?php
list($nn,$l) = explode(" ",trim(fgets(STDIN)));
$rdh = explode(" ",trim(fgets(STDIN)));
sort($rdh);
if ($nn>1){
if ($rdh[0] != 0)
$rfyjmd []= 2*$rdh[0];
if ($rdh[$nn-1] != $l)
$rfyjmd []= 2*($l-$rdh[$nn-1]);
for ($i=0;$i<$nn-1;$i++){
$rfyjmd []= abs($rdh[$i+1]-$rdh[$i]);
}

$val = max($rfyjmd)/2;
}else{
$val = max($l-$rdh[0],$rdh[0]);
}
printf("%0.10f",$val);
?>

<?php
list ($n, $l) = explode(" ", trim(fgets(STDIN)));
$a = explode(" ", trim(fgets(STDIN)));

sort($a, SORT_NUMERIC);

$maxDist = 0;

for ($i = 1; $i < $n; $i++) {
  $maxDist = max($maxDist, $a[$i] - $a[$i - 1]);
}
$maxDist /= 2;
$maxDist = max($maxDist, $a[0]);
$maxDist = max($maxDist, $l - $a[$n - 1]);

printf("%.10f", $maxDist);

<?php
list ($n,$L) = explode(" ",trim(fgets(STDIN)));
$lights = explode(" ",trim(fgets(STDIN)));
sort($lights);
for ($i=1;$i<count($lights);$i++)
{
    $ds[]=$lights[$i]-$lights[$i-1];
}
$edgeL = $lights[0];
$edgeR = $L - $lights[count($lights)-1];
$answer = max(max($ds)/2,$edgeL,$edgeR);
echo $answer = number_format($answer,10,'.',"");

<?php
list($nnnnnn,$l) = explode(" ",trim(fgets(STDIN)));
$rdh = explode(" ",trim(fgets(STDIN)));
sort($rdh);
if ($nnnnnn>1){
if ($rdh[0] != 0)
$rfyjmd []= 2*$rdh[0];
if ($rdh[$nnnnnn-1] != $l)
$rfyjmd []= 2*($l-$rdh[$nnnnnn-1]);
for ($i=0;$i<$nnnnnn-1;$i++){
$rfyjmd []= abs($rdh[$i+1]-$rdh[$i]);
}

$ololol = max($rfyjmd)/2;
}else{
$ololol = max($l-$rdh[0],$rdh[0]);
}
printf("%0.10f",$ololol);
?>

<?php
$d = readline();
$fonari = readline();
//$d = '7 15';
$d = explode(' ',$d);
$n = $d[0];
$l = $d[1];
//$fonari = '15 5 3 7 9 14 0';
$fonari = explode(' ',$fonari);  // 2 5
sort($fonari);
$summa = array();
$i = 0;
$f_start = min($fonari);
$f_finish = $l - max($fonari);
 foreach ($fonari as $v){
           $summa[] = $fonari[$i + 1] - $v;
         $i += 1;
         if ($i == count($fonari) - 1) {
             break;
         }
      }
 $max_distanse = max($summa)/2;
  if ($max_distanse > $f_start && $max_distanse > $f_finish) {
     echo $max_distanse;
  } elseif ($f_start > $max_distanse  && $f_start > $f_finish){
     echo $f_start;
  } else {
     echo $f_finish;
  }

<?php
// 462A     Яблов и простая задача

$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
list($n, $l) = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);
$n = (int) $n;
$l = (int) $l;

$input_line = fgets($in);
$arrN = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

sort($arrN);

$maxLen = 0;

for ($i=0; $i < $n-1; $i++) {
    if (($arrN[$i+1] - $arrN[$i]) > $maxLen) {
        $maxLen = $arrN[$i+1] - $arrN[$i];
    }
}

if ((($arrN[0] - 0) * 2) > $maxLen) {
    $maxLen = $arrN[0] * 2;
}

if ((($l - $arrN[$n-1]) * 2) > $maxLen) {
    $maxLen = ($l - $arrN[$n-1]) * 2;
}

echo $maxLen / 2;

?>

<?php
    $stdin = fopen("php://stdin", "r");
    fscanf(STDIN, "%d%d", $n, $l);
    $line = trim(fgets(STDIN));
    $arr = explode(' ', $line);
    fclose(STDIN);

    sort($arr);

    $dp = array();

    $dp[0] = $arr[0];
    for($i=1; $i<sizeof($arr); $i++)
        $dp[$i] = ($arr[$i] - $arr[$i-1])/2;
    $dp[sizeof($arr)] = $l - $arr[sizeof($arr)-1];

    rsort($dp);

    echo $dp[0] . PHP_EOL;
?>

$d = readline();
$fonari = readline();
//$d = '2 5';
$d = explode(' ',$d);
$n = $d[0];
$l = $d[1];
//$fonari = '2 5';
$fonari = explode(' ',$fonari);  // 2 5
sort($fonari);
$summa = array();
$i = 0;
$f_start = min($fonari);
$f_finish = $l - max($fonari);
 foreach ($fonari as $v){
           $summa[] = $fonari[$i + 1] - $v;
         $i += 1;
         if ($i == count($fonari) - 1) {
             break;
         }
      }
 $max_distanse = max($summa)/2;
  if ($max_distanse > $f_start && $max_distanse > $f_finish) {
     echo $max_distanse;
  } elseif ($f_start > $max_distanse  && $f_start > $f_finish){
     echo $f_start;
  } else {
     echo $f_finish;
  }


<?php
$handle = fopen("php://stdin", "r");

// $handle = fopen('buythestring_input.txt', 'r');
// echo '<pre>';

$t = intval(fgets($handle));

for ($tI = 0; $tI < $t; $tI++) {
    list($n, $c0, $c1, $h) = sscanf(fgets($handle), "%d %d %d %d");
    $s = fgets($handle);

    $minCoins = 0;

    for ($i = 0; $i < $n; $i++) {
        $defaultAmountNeeded = ($s{$i} == '0' ? $c0 : $c1);
        $amountNeededIfChange = ($s{$i} == '0' ? $c1 : $c0) + $h;

        $minCoins += $defaultAmountNeeded <= $amountNeededIfChange ? $defaultAmountNeeded : $amountNeededIfChange;
    }

    echo $minCoins;
    echo "\n";
}

<?php
$h = fopen("php://stdin", "r");

// $handle = fopen('buythestring_input.txt', 'r');
// echo '<pre>';

$t = intval(fgets($handle));

for ($tI = 0; $tI < $t; $tI++) {
    list($n, $c0, $c1, $h) = sscanf(fgets($handle), "%d %d %d %d");
    $s = fgets($handle);

    $minCoins = 0;

    for ($i = 0; $i < $n; $i++) {
        $defaultAmountNeeded = ($s{$i} == '0' ? $c0 : $c1);
        $amountNeededIfChange = ($s{$i} == '0' ? $c1 : $c0) + $h;

        $minCoins += $defaultAmountNeeded <= $amountNeededIfChange ? $defaultAmountNeeded : $amountNeededIfChange;
    }

    echo $minCoins;
    echo "\n";
}


<?php
error_reporting("off");
//158D: Ice Sculptures
//Lesson of the day: When you have a computer do arithmetic for you, it's practically always right. Do not question it when it tells you that 1 + 1 + (-1) + 1 is 2 (and, surprisingly enough, not 3).
$n = trim(fgets(STDIN)); //$n = 8;
$t = explode(" ", trim(fgets(STDIN))); //$t = explode(" ", "1 1 1 1 -1 -1 1 1");
$total = array();
for ($i = 1; $i < $n; $i++) {
    if ($n % $i == 0 && $n / $i > 2) { //needs to divide into the num of statues and also be >= 3 after that.
        $sums = array();
        $leftstanding = $n / $i;
        for ($k = 0; $k < $i; $k++) {
            $sum = 0;
            for ($j = $k; $j < $n; $j += $i) {
                $sum += $t[$j];
            }
            $sums[] = $sum;
        }
        rsort($sums);
        $total[] = $sums[0]; //only the top dogs need to move to the next round
    }
}
rsort($total);
echo $total[0];
?>

<?php
$n =(int) trim(fgets(STDIN));
$line = trim(fgets(STDIN));
$t = explode( ' ', $line);

$k = $n/2+$n%2;
$dlm = array();
for($i=3;$i<=$k;$i++)
    if($n%$i == 0)
        $dlm[]= $i;
$dlm[] = $n;

$lastMax = -1000*20000;
foreach($dlm as $key => $val)
{
    $kv = $n / $val;
    for($i=0;$i<$kv;$i++)
    {
        for($j=0;$j<$val;$j++)
        {
            $sum[$i] += (int)$t[$i+$kv*$j];
        }
    }
    $sum[] = $lastMax;
    $lastMax = max($sum);
    unset($sum);
}
fputs(STDOUT, $lastMax);
?>

<?php
  $input = dataProvider::get();
  $i = 0;
  $sums = array();
    $n = $input['n'];
    for ($i = 1; $i <= $n / 3; $i++) {
        if ($n % $i) {
            continue;
        }

        for($k = 1; $k <= $i; $k++) {
            $sums[] = getSum($k, $i);
        }
  }

  function getSum($start, $step)
  {
      global $input;
      $sum = 0;
      for($i = $start - 1; $i < count($input['items']); $i = $i+$step) {
        $sum += $input['items'][$i];
      }
      return $sum;
  }

  dataProvider::set(max($sums));

  class dataProvider
  {
      public static function get()
      {
          $stdin = file_get_contents('php://stdin');
          $lines = explode("\n", $stdin, 2);
          $lines[1] = explode(' ', $lines[1]);
          return array(
            'n' => intval($lines[0]),
            'items' => $lines[1],
          );
      }

      public static function set($data)
      {
        file_put_contents('php://stdout', $data);
      }
  }
?>

<?php
$dir = fopen("php://stdin", 'r');
$datatxt = stream_get_contents($dir);
$data = explode("\n",$datatxt);

$n=trim($data[0]);

$array = explode(' ', trim($data[1]));

$rating=0;

$i=1;
while(ceil($n/$i)>=3)
{
    if($n/$i==floor($n/$i))
    {
        for($sdvig=0;$sdvig<$i;$sdvig++)
        {
            for($ii=$sdvig;$ii<$n;$ii=$ii+$i)
            {
                $rating+=$array[$ii];
            }
            if(isset($ratingMax))
            {
                if($rating>$ratingMax)
                {
                    $ratingMax=$rating;
                }
            }
            else
            {
                $ratingMax=$rating;
            }
            $rating=0;
        }
    }
    $i++;
}
echo $ratingMax;
?>

<?php
$n = (int) fgets(STDIN);
$a = explode(' ', fgets(STDIN));

$max = array_sum($a);
for ($i = 2; $i < $n * 2 / 3; $i++) {
	if ($n % ($i + 1) == 0) {
		$sector = $n / ($i + 1);
		for ($offset = 0; $offset < $sector; $offset++) {
			$c = 0;
			for ($k = 0; $k <= $i; $k++)
				$c += (int) $a[ $offset + $sector * $k ];
			if ($c > $max) $max = $c;
		}
	}
}
printf("%d", $max);

<?php
fscanf(STDIN, "%d", $n);
$arr=explode(' ',trim(fgets(STDIN)));
function sum ($a, $start, $step){
    GLOBAL $n;
    $result = 0;
    for($k=$start; $k<$n; $k+=$step)
        $result+=$a[$k];
    return $result;
}

$max=sum($arr,0, 1);
for($i=2; $i<=$n/2; $i++){
    if ($n%$i==0 && $n/$i>=3 ){
        for ($j = 0; $j < $i; $j++)
            $max=max($max, sum($arr,$j, $i));
    }
}
fprintf(STDOUT, "%.0f", $max);

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$count = (int)(fgets($fp));
$rating = explode(" ",  str_replace( "\r\n", '', fgets($fp) ) );

$group = searchGroup( $count );

$maxFind = array();
foreach( $group as $key => $val ){
	$max = searchMax( $rating, $key );
	$maxFind[] = max( $max );
}

echo max( $maxFind );

fclose($fp);

function searchMax( $rating, $period )
{
	$groupSum = array();
	$i = 1;
	foreach( $rating as $value ){
		$groupSum[$i] += $value;
		$i++;
		if( $i > $period )
		{
			$i = 1;
		}
	}
	return $groupSum;
}

function searchGroup( $number )
{
	$aResult = array();
	$middle = $number / 2;
	$i = 1;
	while( $i <= $middle )
	{
		if( $number % $i == 0 ){
			if( $number / $i > 2 )
			{
				$aResult[$i] = true;
			}
			if( $i > 2 )
			{
				$aResult[$number / $i] = true;
			}
		}
		$i++;
	}

	return $aResult;
}
?>

<?php
$n = trim(fgets(STDIN));
$balls = explode(' ', trim(fgets(STDIN)));
$max = array_sum($balls);
for ($i = 2; $i < $n * 2 / 3; $i++) {
        if ($n % ($i + 1) == 0) {
                $sector = $n / ($i + 1);
                for ($offset = 0; $offset < $sector; $offset++) {
                        $sum = 0;
                        for ($k = 0; $k <= $i; $k++) {
                                $sum += (int) $balls[ $offset + $sector * $k ];
                        }
                        if ($sum > $max){
                            $max = $sum;
                       }
                }
        }
}
echo $max."\n";
?>

<?php
    while(($line = fgets(STDIN)) != false)
    {
        $arr[] = $line;
    }
    $input = explode(" ", $arr[1]);
    $temp = 0;
    if (count($input) == 3)
    {
        $temp = $input[0] + $input[1] + $input[2];
        fputs(STDOUT, $temp);
        return;
    }
    $chislo = count($input) / 2 - 1;
    $sums = array();
    for ($i = 1; $i <= $chislo; $i++)
    {
        if (count($input) % $i != 0)
        {
            continue;
        }
        for ($k = 0; $k < $i; $k++)
        {
            $temp = 0;
            $j = $k;
            while ($j < count($input))
            {
                if (($j - $k) % $i == 0)
                {
                    $temp = $temp + $input[$j];
                }
                $j = $j + $i;
            }
            $sums[] = $temp;
        }
    }
    $max = $sums[0];
    for ($i = 1; $i < count($sums); $i++)
    {
        if ($max < $sums[$i])
        {
            $max = $sums[$i];
        }
    }
    fputs(STDOUT, $max);
?>

<?php

fscanf(STDIN ,"%d" , $n);
$a = explode(" " , trim(fgets(STDIN)));
$ans = array_sum($a);
for($i=2;$i<$n/2;$i++) {
	if($n % $i != 0) continue;
	for($j=0;$j<$i;$j++) {
		$tmp = 0;
		for($k=$j;$k<$n;$k+=$i) {
			$tmp += $a[$k];
		}
		if($tmp > $ans) $ans = $tmp;
	}
}
echo $ans;
?>

<?php
//set_time_limit(10);
/**
 * @author icyken
 * @copyright 2012
 */

$stdin = fopen('php://stdin', 'r');
$stdout = fopen('php://stdout', 'w');

//$stdin = fopen("input.txt",'r');

$inputFirstLine     = explode(" ",trim(fgets($stdin)));
$n = $inputFirstLine[0];

$values = explode(" ",trim(fgets($stdin)));

for ($i=3; $i<$n; $i++)
if ($n % $i==0) $del[] = $i;

function sumP($arr)
{
    foreach ($arr as $keyA=>$valueA) $r = $r + $valueA;
    return $r;
}

$aP = sumP($values);

$i = count($del);
while ($i>0)
{
    $ugolnik = $del[$i-1];
    $countUgolnik = $n / $ugolnik;
    while ($countUgolnik>0)
    {
        $sx = $countUgolnik-1;

        $summa = 0;
        while ($sx<=$n)
        {
            $summa = $summa + $values[$sx];
            $sx =  $sx + ($n/$ugolnik);
        }

//        echo $summa."\n";

        if ($aP<$summa) $aP = $summa;
        $countUgolnik--;
    }

    $i--;
}

echo $aP;

?>

<?php
          $stdin = file_get_contents('php://stdin');
          $lines = explode("\n", $stdin, 2);
          $lines[1] = explode(' ', $lines[1]);
          $input = array(
            'n' => intval($lines[0]),
            'items' => $lines[1],
          );
  $i = 0;
  $sums = array();
    $n = $input['n'];
    for ($i = 1; $i <= $n / 3; $i++) {
        if ($n % $i) { continue; }
        for($k = 1; $k <= $i; $k++) {
            $sums[] = getSum($k, $i);
        }
  }
  function getSum($start, $step)
  {
      global $input;
      $sum = 0;
      for($i = $start - 1; $i < count($input['items']); $i = $i+$step) {
        $sum += $input['items'][$i];
      }
      return $sum;
  }

    file_put_contents('php://stdout', max($sums));
 ?>

<?php
    function InputNumbers($count) {
        return explode(' ', fgets(STDIN));
    }

    $columns_count = intval(fgets(STDIN));
    $columns = InputNumbers($columns_count);

    $indexes = array();

    for ($i = 2; $i <= $columns_count/3; ++$i) {
        if ($columns_count % $i == 0) {
            $indexes[] = $i;
        }
    }

    $max_sum = false;
    foreach ($indexes as $index) {
        $chunks = array_chunk($columns, $index);
        $sum = array();

        foreach ($chunks as $chunk) {
            foreach ($chunk as $key=>$item) {
                if (!isset($sum[$key])) {
                    $sum[$key] = 0;
                }
                $sum[$key] += $item;
            }
        }

        rsort($sum);

        if ($max_sum === false || $max_sum < $sum[0]) {
            $max_sum = $sum[0];
        }
    }

    $sum = array_sum($columns);
    if ($max_sum === false || $sum > $max_sum) {
        echo $sum;
    } else {
        echo $max_sum;
    }
?>

<?php
$fp = fopen('php://stdin', 'r');
$tmp='';
while($line = fgets($fp)) { $tmp.=$line; }
$tmp=explode("\n",$tmp);
$num=(int)$tmp[0];
$scarray=explode(" ",$tmp[1]);
$vars=array();
$res=array();
$result=0;
if ($num<6) {
	for($i=0;$i<$num;$i++) $result+=(int)$scarray[$i];
} else {
	array_push($vars,0);
	for($i=1;$i<$num/3;$i++) {
		if ($num % ($i+1)==0)
			array_push($vars,$i);
	}
	for ($i=0;$i<count($vars);$i++) {
		for($k=0;$k<$vars[$i]+1;$k++){
			$temp=0;
			for($j=$k;$j<$num;$j+=$vars[$i]+1) {
				$temp+=(int)$scarray[$j];
			}
			array_push($res,$temp);
		}
	}
	$result=max($res);
}
echo $result;
?>

<?php
    $n = trim(fgets(STDIN));
    $ball=explode(' ',trim(fgets(STDIN)));
   $min=null;
    for ($i=1; $i<=$n; $i++){
        if (($n%$i>0) or ($n/$i<3)) {continue;}
        for ($t=0; $t<=$i-1; $t++){
            $j=$t; $count=$ball[$j];
            while ($j<$n){

               $j=$j+$i;

               $count=$count+$ball[$j];

            }
            if ($min<=$count) $min=$count;
        }
    }
    print($min);

?>

<?php
    $sum=0;
    $max=0;

    fscanf(STDIN, "%d\n", $sculpture_number);

        $line = trim(fgets(STDIN));
        $line_array=explode(" ",$line);
        for($i=0;$i<$sculpture_number;$i++){
            $max+=intval($line_array[$i]);
        }

     for($i=1;$i<$sculpture_number;$i++){
         if ($sculpture_number % $i==0 && $sculpture_number/$i!=2){
             for($j=1;$j<=$i;$j++){
                $sum=0;
                 for ($k=$j-1;$k<$sculpture_number;$k=$k+$i){
                    $sum+=intval($line_array[$k]);
                 }
                if($sum>$max){$max=$sum;}
             }
         }
     }

   echo $max;
?>

<?
fscanf(STDIN, "%d\n", $number);
$line=trim(fgets(STDIN));
$t=explode(" ",$line);
$count=count($t);
if($count!=$number||$number<3||$number>20000)exit();
$res=array();
for($i=1;$i<$count;$i++){
	if($count%$i!=0 || ($count/$i)<3)continue;
	$count/$i;
	for($n=0;$n<$i;$n++){
		for($a=$n;$a<$count;$a+=$i){
			$val=$t[$a];
			if($val<-1000||$val>1000)exit();
			$res[$i.$n]+=$val;
		}
	}
}
echo max($res);
?>

<?php
fscanf(STDIN, "%d\n", $iSculptures);

$sRates = fgets(STDIN, 122880);

$aRates = explode(' ', $sRates);

if ($iSculptures != count($aRates) || $iSculptures < 3 || $iSculptures > 20000) {
	die;
}

foreach ($aRates as &$iRate) {
	$iRate = (int) $iRate;

	if ($iRate < 0) {
		$bHaveNegative = true;
	}
}

$iIterations = floor($iSculptures / 3);

for ($i = 1; $i <= $iIterations; $i ++) {

	$aTempRates = $aRates;
	if ($iSculptures % $i == 0) {
		for ($fi = 1; $fi <= $i; $fi ++) {

			$iReplaced = $aTempRates[$fi - 1];
			array_push($aTempRates, $iReplaced);

			$iCurRate = 0;
			$iTop = $iSculptures + $fi;

			for ($j = $fi; $j < $iTop ; $j += $i) {
				$iCurRate += $aTempRates[$j];
			}

			if (!isset($iMaxRate)) {
				$iMaxRate = $iCurRate;

				if (!isset($bHaveNegative)) {
					break 2;
				}
			} else {
				$iMaxRate = max($iCurRate, $iMaxRate);
			}
		}
	}
}

echo $iMaxRate;

<?
$fp=fopen('php://stdin', 'r');
$lines=stream_get_contents($fp);

$lines=trim($lines);
$lines=explode("\n", $lines);

$points=trim($lines[0]);
$dots=explode(" ", $lines[1]);

$max=array_sum($dots);
if ($points>5)
{
    $dels=del($points);
    foreach ($dels as $d)
    {
        for ($c=1; $c<=$d; $c++)
        {
            $tmp=0;
            $n=0;
            for ($i=0+$c; $i<=$points; $i=$i+$d)
            {
                $tmp+=$dots[$i-1];
                $n++;
                //echo "{$dots[$i-1]} ";
            }
            //echo " = $tmp<br>";
            if($n>=3)
            if ($tmp>$max)
                $max=$tmp;
        }
    }
}

echo $max;

function del($chislo)
{
    for($i = 1; $i < $chislo; $i++)
    {
     if(($chislo % $i)==0)
       $dels[]=$i;
    }
    return $dels;
}
?>

<?php
    $arr = array();
    while(($line = fgets(STDIN)) != false)
    {
        $arr[] = $line;
    }

$number = $arr[0];
$array = explode(" ", $arr[1]);
$delitels = array();
$summa = 0;
$sum = 0;

//найдём делители числа 8
for ($i=2; $i<$number; $i++) {
    if ($number%$i == 0 && $number/$i >= 3) {
        $delitels[] = $i;
    }
}

for ($i=0; $i<$number; $i++) {
    $summa += $array[$i];
}

//1 - Если число простое - то ответ - начальная сумма

if (!empty($delitels)) {
    foreach ($delitels as $del) {
        for ($j=0; $j<$del; $j++) { //Пройдём по делителю с шагом = 1
            $sum = 0;
            for ($i=$j; $i<$number; $i+=$del) {
                $sum += $array[$i];
            }
            if ($sum > $summa) {
                $summa = $sum;
            }
        }
    }
}

    fputs(STDOUT, $summa);
?>

<?php
$dir = fopen("php://stdin", 'r');
$datatxt = stream_get_contents($dir);
$data = explode("\n",$datatxt);

$n=trim($data[0]);

$array = explode(' ', trim($data[1]));

$rating=0;
$ratingMax=0;

$i=1;
while(ceil($n/$i)>=3)
{
    for($sdvig=0;$sdvig<=$i;$sdvig++)
    {
        for($ii=$sdvig;$ii<$n;$ii=$ii+$i)
        {
            $rating+=$array[$ii];

        }
        if($rating>$ratingMax)
        {
            $ratingMax=$rating;
        }
        $rating=0;
    }
    $i++;
}

echo $ratingMax;
?>

<?php
$dir = fopen("php://stdin", 'r');
$datatxt = stream_get_contents($dir);
$data = explode("\n",$datatxt);

$n=trim($data[0]);

$array = explode(' ', trim($data[1]));

$rating=0;

$i=1;
while(ceil($n/$i)>=3)
{
    for($sdvig=0;$sdvig<=$i;$sdvig++)
    {
        for($ii=$sdvig;$ii<$n;$ii=$ii+$i)
        {
            $rating+=$array[$ii];

        }
        if(!empty($ratingMax))
        {
            if($rating>$ratingMax)
            {
                $ratingMax=$rating;
            }
        }
        else
        {
            $ratingMax=$rating;
        }
        $rating=0;
    }
    $i++;
}
echo $ratingMax;
?>

<?php
$n = (int) fgets(STDIN);
$a = explode(' ', fgets(STDIN));

$max = 0;
for ($i = 2; $i < $n * 2 / 3; $i++) {
	if ($n % ($i + 1) == 0) {
		$sector = $n / ($i + 1);
		for ($offset = 0; $offset < $sector; $offset++) {
			$c = 0;
			for ($k = 0; $k <= $i; $k++)
				$c += (int) $a[ $offset + $sector * $k ];
			if ($c > $max) $max = $c;
		}
	}
}
printf("%d", $max);

<?php
fscanf(STDIN, "%d", $n);
$arr=explode(' ',trim(fgets(STDIN)));
function sum ($a, $start, $step){
    $result = 0;
    for($k=$start; $k<count($a); $k+=$step)
        $result+=$a[$k];
    return $result;
}

$max=0;
for($i=3; $i<=floor($n/2); $i++){
    if ($n%$i==0){
        for ($j = 0; $j < $i-1; $j++)
            $max=max($max, sum($arr,$j, $n/$i));
    }
}
$max=max($max, sum($arr,0, 1));
fprintf(STDOUT, "%.0f", $max);

<?php
fscanf(STDIN, "%d", $n);
$arr=explode(' ',trim(fgets(STDIN)));
function sum ($a, $start, $step){
    GLOBAL $n;
    $result = 0;
    for($k=$start; $k<$n; $k+=$step)
        $result+=$a[$k];
    return $result;
}

$max=sum($arr,0, 1);
for($i=2; $i<=$n/2; $i++){
    if ($n%$i==0){
        for ($j = 0; $j < $i; $j++)
            $max=max($max, sum($arr,$j, $i));
    }
}
fprintf(STDOUT, "%.0f", $max);

<?php
fscanf(STDIN, "%d", $n);
$arr=explode(' ',trim(fgets(STDIN)));
function sum ($a, $start, $step){
    $result = 0;
    for($k=$start; $k<count($a); $k+=$step)
        $result+=$a[$k];
    return $result;
}
$max=0;
for($i=3; $i<=floor($n/2); $i++){
    if ($n%$i==0){
        for ($j = 0; $j < $i-1; $j++)
            $max=max($max, sum($arr,$j, $n/$i));
    }
}
fprintf(STDOUT, "%.0f", $max);

<?php
fscanf(STDIN, "%d", $n);
$arr=explode(' ',trim(fgets(STDIN)));
function sum ($a, $start, $step){
    GLOBAL $n;
    $result = 0;
    for($k=$start; $k<$n; $k+=$step)
        $result+=$a[$k];
    return $result;
}

$max=sum($arr,0, 1);
for($i=2; $i<=$n/2; $i++){
    if ($n%$i==0){
        for ($j = 0; $j < $i-1; $j++)
            $max=max($max, sum($arr,$j, $i));
    }
}
fprintf(STDOUT, "%.0f", $max);

<?php
$n =(int) trim(fgets(STDIN));
$line = trim(fgets(STDIN));
$t = explode( ' ', $line);

$k = $n/2+$n%2;
$dlm = array();
for($i=3;$i<=$k;$i++)
    if($n%$i == 0)
        $dlm[]= $i;
$dlm[] = $n;

$lastMax = 0;
foreach($dlm as $key => $val)
{
    $kv = $n / $val;
    for($i=0;$i<$kv;$i++)
    {
        for($j=0;$j<$val;$j++)
        {
            $sum[$i] += (int)$t[$i+$kv*$j];
        }
    }
    $sum[] = $lastMax;
    $lastMax = max($sum);
    unset($sum);
}
fputs(STDOUT, $lastMax);
?>

<?php

function getVariants($n){
    $a=$n;
    $res=array($n);
    if($n%5==0){
        while($a>5){
            $res[]=$a/2;
            $a=$a/2;
        }
        return $res;
    }elseif($n%4==0){
        while($a>4){
            $res[]=$a/2;
            $a=$a/2;
        }
        return $res;
    }elseif($n%3==0){
        while($a>3){
            $res[]=$a/2;
            $a=$a/2;
        }
        return $res;
    }else{
        return $n;
    }

}

$n= trim(fgets(STDIN));
$balls=explode(' ',trim(fgets(STDIN)));

$max=array_sum($balls);
$variants=getVariants($n);

$c=count($variants);
if($c==1){
    echo array_sum($balls);
}else{
    for($i=1;$i<$c;$i++){
        $maxEven=0;
        $maxOdd=0;
        for($j=0;$j<$n;$j=$j+$n/$variants[$i]){
            $maxOdd+=$balls[$j];
        }
        for($j=1;$j<$n;$j=$j+$n/$variants[$i]){
            $maxEven+=$balls[$j];
        }
        if($maxEven>$max){
            $max=$maxEven;
        }
        if($maxOdd>$max){
            $max=$maxOdd;
        }
    }
    echo $max;
}

?>

<?php
    while(($line = fgets(STDIN)) != false)
    {
        $arr[] = $line;
    }
    $input = explode(" ", $arr[1]);
    $chislo = floor(sqrt(count($input)));
    $sums = array();
    for ($i = 1; $i <= $chislo; $i++)
    {
        for ($k = 0; $k < $i; $k++)
        {
            $temp = 0;
            $j = $k;
            while ($j < count($input))
            {
                if (($j - $k) % $i == 0)
                {
                    $temp = $temp + $input[$j];
                }
                $j = $j + $i;
            }
            $sums[] = $temp;
        }
    }
    $max = $sums[0];
    for ($i = 1; $i < count($sums); $i++)
    {
        if ($max < $sums[$i])
        {
            $max = $sums[$i];
        }
    }
    fputs(STDOUT, $max);
?>

<?php
    while(($line = fgets(STDIN)) != false)
    {
        $arr[] = $line;
    }
    $input = explode(" ", $arr[1]);
    $chislo = floor(sqrt(count($input)));
    $sums = array();
    for ($i = 1; $i <= $chislo; $i++)
    {
        if (count($input) % $i != 0)
        {
            continue;
        }
        for ($k = 0; $k < $i; $k++)
        {
            $temp = 0;
            $j = $k;
            while ($j < count($input))
            {
                if (($j - $k) % $i == 0)
                {
                    $temp = $temp + $input[$j];
                }
                $j = $j + $i;
            }
            $sums[] = $temp;
        }
    }
    $max = $sums[0];
    for ($i = 1; $i < count($sums); $i++)
    {
        if ($max < $sums[$i])
        {
            $max = $sums[$i];
        }
    }
    fputs(STDOUT, $max);
?>

<?php
    while(($line = fgets(STDIN)) != false)
    {
        $arr[] = $line;
    }
    $input = explode(" ", $arr[1]);
    $chislo = count($input) / 2;
    $sums = array();
    for ($i = 1; $i <= $chislo; $i++)
    {
        if (count($input) % $i != 0)
        {
            continue;
        }
        for ($k = 0; $k < $i; $k++)
        {
            $temp = 0;
            $j = $k;
            while ($j < count($input))
            {
                if (($j - $k) % $i == 0)
                {
                    $temp = $temp + $input[$j];
                }
                $j = $j + $i;
            }
            $sums[] = $temp;
        }
    }
    $max = $sums[0];
    for ($i = 1; $i < count($sums); $i++)
    {
        if ($max < $sums[$i])
        {
            $max = $sums[$i];
        }
    }
    fputs(STDOUT, $max);
?>

<?php
    while(($line = fgets(STDIN)) != false)
    {
        $arr[] = $line;
    }
    $input = explode(" ", $arr[1]);
    $chislo = count($input) / 2 - 1;;
    $sums = array();
    for ($i = 1; $i <= $chislo; $i++)
    {
        if (count($input) % $i != 0)
        {
            continue;
        }
        for ($k = 0; $k < $i; $k++)
        {
            $temp = 0;
            $j = $k;
            while ($j < count($input))
            {
                if (($j - $k) % $i == 0)
                {
                    $temp = $temp + $input[$j];
                }
                $j = $j + $i;
            }
            $sums[] = $temp;
        }
    }
    $max = $sums[0];
    for ($i = 1; $i < count($sums); $i++)
    {
        if ($max < $sums[$i])
        {
            $max = $sums[$i];
        }
    }
    fputs(STDOUT, $max);
?>

<?php

fscanf(STDIN ,"%d" , $n);
$a = explode(" " , trim(fgets(STDIN)));
$ans = array_sum($a);
for($i=2;$i<=$n;$i++) {
	if($n % $i != 0) continue;
	for($j=0;$j<$i;$j++) {
		$tmp = 0;
		for($k=$j;$k<$n;$k+=$i) {
			$tmp += $a[$k];
		}
		if($tmp > $ans) $ans = $tmp;
	}
}
echo $ans;
?>

<?php
    function InputNumbers($count) {
        return explode(' ', fgets(STDIN));
    }

    $columns_count = intval(fgets(STDIN));
    $columns = InputNumbers($columns_count);

    $indexes = array();

    for ($i = 2; $i <= $columns_count/3; ++$i) {
        if ($columns_count % $i == 0) {
            $indexes[] = $i;
        }
    }

    $max_sum = 0;
    foreach ($indexes as $index) {
        $chunks = array_chunk($columns, $index);
        $sum = array();

        foreach ($chunks as $chunk) {
            foreach ($chunk as $key=>$item) {
                if (!isset($sum[$key])) {
                    $sum[$key] = 0;
                }
                $sum[$key] += $item;
            }
        }

        rsort($sum);
        if ($max_sum < $sum[0]) {
            $max_sum = $sum[0];
        }
    }

    $sum = array_sum($columns);
    if ($sum > $max_sum) {
        echo $sum;
    } else {
        echo $max_sum;
    }
?>

<?php
    function InputNumbers($count) {
        return explode(' ', fgets(STDIN));
    }

    $columns_count = intval(fgets(STDIN));
    $columns = InputNumbers($columns_count);

    $indexes = array();

    for ($i = 2; $i <= $columns_count/3; ++$i) {
        $indexes[] = $i;
    }

    $max_sum = 0;
    foreach ($indexes as $index) {
        $chunks = array_chunk($columns, $index);
        $sum = array();

        foreach ($chunks as $chunk) {
            foreach ($chunk as $key=>$item) {
                if (!isset($sum[$key])) {
                    $sum[$key] = 0;
                }
                $sum[$key] += $item;
            }
        }

        rsort($sum);
        if ($max_sum < $sum[0]) {
            $max_sum = $sum[0];
        }
    }

    $sum = array_sum($columns);
    if ($sum > $max_sum) {
        echo $sum;
    } else {
        echo $max_sum;
    }
?>

<?php
    $n = trim(fgets(STDIN));
    $ball=explode(' ',trim(fgets(STDIN)));
   $min=-1000000;
    for ($i=1; $i<=$n; $i++){
        if (($n%$i>0) or ($n/$i<3)) {continue;}
        for ($t=0; $t<=$i; $t++){
            $j=$t; $count=$ball[$j];
            while ($j<=$n){
               $j=$j+$i;
               $count=$count+$ball[$j];

               if ($min<=$count) $min=$count;
            }
        }
    }
    print($min);

?>

<?php
    $n = trim(fgets(STDIN));
    $ball=explode(' ',trim(fgets(STDIN)));
   $min=-1000000;
    for ($i=1; $i<=$n; $i++){
        if (($n%$i>0) or ($n/$i<3)) {continue;}
        for ($t=0; $t<=$i-1; $t++){
            $j=$t; $count=$ball[$j];
            while ($j<$n){

               $j=$j+$i;

               $count=$count+$ball[$j];

            }
            if ($min<=$count) $min=$count;
        }
    }
    print($min);

?>

<?php
    $sum=0;
    $max=0;

    fscanf(STDIN, "%d\n", $sculpture_number);

        $line = trim(fgets(STDIN));
        $line_array=explode(" ",$line);
        for($i=0;$i<$sculpture_number;$i++){
            $max+=intval($line_array[$i]);
        }

     for($i=1;$i<$sculpture_number;$i++){
         if ($sculpture_number % $i==0){
             for($j=1;$j<=$i;$j++){
                $sum=0;
                 for ($k=$j-1;$k<$sculpture_number;$k=$k+$i){
                    $sum+=intval($line_array[$k]);
                 }
                if($sum>$max){$max=$sum;}
             }
         }
     }

   echo $max;
?>

<?
fscanf(STDIN, "%d\n", $number);
$line=trim(fgets(STDIN));
$t=explode(" ",$line);
$count=count($t);
if($count!=$number||$number<3||$number>20000)exit();
$res=array();
for($i=1;$i<$count;$i++){
	if($count%$i!=0)continue;
	for($n=0;$n<=$i;$n++){
		for($a=$n;$a<$count;$a+=$i){
			$val=$t[$a];
			if($val<-1000||$val>1000)exit();
			$res[$i.$n]+=$val;
		}
	}
}
echo max($res);
?>

<?
fscanf(STDIN, "%d\n", $number);
$line=trim(fgets(STDIN));
$t=explode(" ",$line);
$count=count($t);
if($count!=$number||$number<3||$number>20000)exit();
$res=array();
for($i=1;$i<$count;$i++){
	if($count%$i!=0 && $count/$i<3)continue;
	for($n=0;$n<$i;$n++){
		for($a=$n;$a<$count;$a+=$i){
			$val=$t[$a];
			if($val<-1000||$val>1000)exit();
			$res[$i.$n]+=$val;
		}
	}
}
echo max($res);
?>

<?
fscanf(STDIN, "%d\n", $number);
$line=trim(fgets(STDIN));
$t=explode(" ",$line);
$count=count($t);
if($count!=$number||$number<3||$number>20000)exit();
$res=array();
for($i=1;$i<$count;$i++){
	if($count%$i!=0 && $count/$i<3)continue;
	for($n=0;$n<$i;$n++){
		for($a=$n;$a<$count;$a+=$i){
			$val=$t[$a];
			if($val<-1000||$val>1000)exit();
			$res[$i.$n]+=$val;
		}
	}
}
var_dump($res);
echo max($res);
?>

<?
$fp=fopen('php://stdin', 'r');
$lines=stream_get_contents($fp);

$lines=trim($lines);
$lines=explode("\n", $lines);

$points=trim($lines[0]);
$dots=explode(" ", $lines[1]);

$max=array_sum($dots);
if ($points%2==0)
{
    $dels=del($points);
    foreach ($dels as $d)
    {
        for ($c=1; $c<=$d; $c++)
        {
            $tmp=0;
            for ($i=0+$c; $i<=$points; $i=$i+$d)
            {
                $tmp+=$dots[$i-1];
                //echo "{$dots[$i-1]} ";
            }
            //echo " = $tmp<br>";
            if ($tmp>$max)
                $max=$tmp;
        }
    }
}

echo $max;

function del($chislo)
{
    for($i = 2; $i < $chislo; $i++)
    {
     if(($chislo % $i)==0)
       $dels[]=$i;
    }
    return $dels;
}

?>

<?
$fp=fopen('php://stdin', 'r');
$lines=stream_get_contents($fp);

$lines=trim($lines);
$lines=explode("\n", $lines);

$points=trim($lines[0]);
$dots=explode(" ", $lines[1]);

//$points=44;
$dels=del($points);

$max=array_sum($dots);

foreach ($dels as $d)
{
    for ($c=1; $c<=$d; $c++)
    {
        $tmp=0;
        for ($i=0+$c; $i<=$points; $i=$i+$d)
        {
            $tmp+=$dots[$i-1];

        }
        if ($tmp>$max)
            $max=$tmp;
    }
}

echo $max;

function del($chislo)
{
    for($i = 2; $i < $chislo; $i++)
    {
     if(($chislo % $i)==0)
       $dels[]=$i;
    }
    return $dels;
}
?>

<?
$fp=fopen('php://stdin', 'r');
$lines=stream_get_contents($fp);

$lines=trim($lines);
$lines=explode("\n", $lines);

$points=trim($lines[0]);
$dots=explode(" ", $lines[1]);

$max=array_sum($dots);
if ($points%2==0 and $points>5)
{
    $dels=del($points);
    foreach ($dels as $d)
    {
        for ($c=1; $c<=$d; $c++)
        {
            $tmp=0;
            for ($i=0+$c; $i<=$points; $i=$i+$d)
            {
                $tmp+=$dots[$i-1];
                //echo "{$dots[$i-1]} ";
            }
            //echo " = $tmp<br>";
            if ($tmp>$max)
                $max=$tmp;
        }
    }
}

echo $max;

function del($chislo)
{
    for($i = 2; $i < $chislo; $i++)
    {
     if(($chislo % $i)==0)
       $dels[]=$i;
    }
    return $dels;
}
?>

<?
$fp=fopen('php://stdin', 'r');
$lines=stream_get_contents($fp);

$lines=trim($lines);
$lines=explode("\n", $lines);

$points=trim($lines[0]);
$dots=explode(" ", $lines[1]);

$max=array_sum($dots);
if ($points%2==0 and $points>5)
{
    $dels=del($points);
    foreach ($dels as $d)
    {
        for ($c=1; $c<=$d; $c++)
        {
            $tmp=0;
            $n=0;
            for ($i=0+$c; $i<=$points; $i=$i+$d)
            {
                $tmp+=$dots[$i-1];
                $n++;
                //echo "{$dots[$i-1]} ";
            }
            //echo " = $tmp<br>";
            if($n>=3)
            if ($tmp>$max)
                $max=$tmp;
        }
    }
}

echo $max;

function del($chislo)
{
    for($i = 1; $i < $chislo; $i++)
    {
     if(($chislo % $i)==0)
       $dels[]=$i;
    }
    return $dels;
}
?>

<?PHP
$putdata = fopen("php://stdin", "r");
$data = fread($putdata, 500000);
fclose($putdata);
$tr = fopen('php://output', 'w');
$t = explode("\n",$data);
$input = $t[0];
$input2 = $t[1];
$r=explode(' ',$input2);
$sum=0;
for($i=0;$i<=count($r)-1;$i++){
$sum+=$r[$i];
}
$count=count($r);
$dels=array();
$max=$sum;
for ($i=2;$i<=$count;$i++){
If ($count % $i ==0){$dels[]=$i;}
}
If (sizeof($dels)<1){
$output=$sum;
}else{
$sums=array();
for ($z=0;$z<=count($dels)-1;$z++){
$del=$dels[$z];
for($h=0;$h<=$count-1;$h++){
for($s=0;$s<=$del-1;$s++){
$sums[$s]+=$r[$del*$h+$s];
}
}
for ($h=0;$h<=$del-1;$h++){
if($sums[$h]>$max){
$max=$sums[$h];}
}
}
$output=$max;
}
fputs($tr, $output );

<?php
//$t2 = time();

$line1 = (int)trim(fgets(STDIN));
$line2 = trim(fgets(STDIN));

//error_reporting(null);

$f = function ($n, $points) {
    //var_dump($n);
    //var_dump($points);

    $sum = array();
    $len = count($points);
    $d = findDel((int)$len);
    //var_dump($d);exit();
    $sum['0_1'] = 0;

    /*for($i=0; $i<$len; $i++) {
        $sum['0_1'] += (int)$points[$i];

        for($j = 0; $j <= count($d); $j++) {
            foreach($d as $item) {
                if($j<$item && (($i+$j) % $item === 0)) {
                    //echo $item===4 && $j==4 ?'<'.$points[$i].'|'.$item.'|'.$j.">\r\n":'';
                    if(!isset($sum[$j.'_'.$item]))
                        $sum[$j.'_'.$item] = 0;
                    $sum[$j.'_'.$item] += (int)$points[$i];
                }
            }
        }
    }*/

    foreach($d as $item) {
        for($i = 0; $i < $len; $i+=$item) {
            for($j = 0; $j <= count($d); $j++) {
                if($j<$item) {
                    if(isset($points[$i+$j])) {
                        //echo $item===4 && $j==0 ?'<'.$points[$i+$j].'|'.$item.'|'.$j.">\r\n":'';
                        if(!isset($sum[$j.'_'.$item]))
                            $sum[$j.'_'.$item] = 0;
                        $sum[$j.'_'.$item]+=$points[$i+$j];
                    }
                }
            }
        }
    }

    //var_dump($sum);

    return max(array_sum($points), max($sum));
};

function findDel($ch) {
    $arr = array();
    for($s = 2; $s < $ch; $s++) {
        if ($s< floor($ch/2) && $ch % $s==0) {
            $arr[] = $s;
        }
        if($s>floor($ch/2))
            break;
    }
    return $arr;
}

//$line1 = 9;
//$line2 = '';
$lineArray2 = explode(' ', $line2);

echo $f($line1, $lineArray2);

//echo "\r\n|=>", (time() - $t2), "\r\n";


<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 10; $m = 3;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "7 8 10");
sort($dirtystairs, SORT_NUMERIC);
$numdirty = count($dirtystairs);
$counter = 1;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1) {
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $first = "yes";
        $counter = 1; //reset if it wasn't 1 already
    }
}

if (in_array($n, $dirtystairs) || in_array(1, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 123; $m = 13;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "36 73 111 2 92 5 47 55 48 113 7 78 37");
sort($dirtystairs, SORT_NUMERIC);
$numdirty = count($dirtystairs);
$counter = 0;
$first = "yes";

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1 && $first == "yes") { //this statement probably needs improving
        $first = "no";
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $first = "yes";
        $counter = 0; //reset if it wasn't 0 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 10; $m = 3;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "7 8 10");
sort($dirtystairs, SORT_NUMERIC);
$numdirty = count($dirtystairs);
$counter = 1;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1) {
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $first = "yes";
        $counter = 1; //reset if it wasn't 1 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 10; $m = 3;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "7 8 10");
sort($dirtystairs);
$numdirty = count($dirtystairs);
$counter = 0;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1 || $dirtystairs[$i] == $dirtystairs[$i + 1] - 1) { //this statement probably needs improving
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $counter = 0; //reset if it wasn't 0 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 123; $m = 13;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "36 73 111 2 92 5 47 55 48 113 7 78 37");
sort($dirtystairs, SORT_NUMERIC);
print_r($dirtystairs);
$numdirty = count($dirtystairs);
$counter = 0;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1 || $dirtystairs[$i] == $dirtystairs[$i + 1] - 1) { //this statement probably needs improving
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $counter = 0; //reset if it wasn't 0 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 123; $m = 13;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "36 73 111 2 92 5 47 55 48 113 7 78 37");
sort($dirtystairs, SORT_NUMERIC);
$numdirty = count($dirtystairs);
$counter = 0;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1 || $dirtystairs[$i] == $dirtystairs[$i + 1] - 1) { //this statement probably needs improving
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $counter = 0; //reset if it wasn't 0 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>


<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c, $d, $e) = explode(" ", trim(fgets(STDIN)));
     if($d < $e)
     {
          $f = floor($e / $d);
          $g = $e % $d;
          $e -= $d * min($b, $f);
          if($c >= $e)
          {
               print "YES\n";
          }
          else
          {
               print "NO\n";
          }
     }
     elseif($d == $e)
     {
          print "YES\n";
     }
     elseif($d > $e)
     {
          if($c >= $e)
          {
               print "YES\n";
          }
          else
          {
               print "NO\n";
          }
     }
}
?>

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iAvg = floor($aArray[3]/$aArray[2]);
    if ($iAvg <= $aArray[0]) {
        if (($iAvg*$aArray[2] + $aArray[1]) >= $aArray[3]){
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    } elseif ($iAvg > $aArray[0]) {
        if(($aArray[0]*$aArray[2] + $aArray[1]) >= $aArray[3]){
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    } else {
        echo "NO\n";
    }
}

<?php
$count = fgets(STDIN);
for ($i = 0; $i < $count; $i++){
	list($a, $b, $n, $S) = explode(' ', fgets(STDIN));
	if($a * $n < $S){
		printf("%s\n", $a * $n + $b >= $S ? 'YES':'NO');
	} else {
		printf("%s\n", $b >= $S % $n ? 'YES':'NO');
	}
}

<?php
$q = trim(fgets(STDIN));

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = explode(" ", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

    if (intval($s / $n) <= $a && $s % $n <= $b) {
        $status = true;
    } else if (intval($s / $n) > $a && $s - ($a * $n) <= $b) {
        $status = true;
    }
   /*if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && $s%$n == 0 && intval($s/$n) <= $a) {
        $status = true;
    } else {
       if ($s % $n <= $b && intval($s / $n) <= $a) {
           $status = true;
       }
   }*/

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iAvg = floor($aArray[3]/$aArray[2]);
    if ($iAvg <= $aArray[0]) {
        if (($iAvg*$aArray[2] + $aArray[1]) >= $aArray[3]){
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    } else {
        echo "NO\n";
    }
}

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    $aArray = explode(' ', trim(fgets(STDIN)));
    if (floor($aArray[3]/$aArray[2]) <= $aArray[0]) {
        if ((floor($aArray[3]/$aArray[2])*$aArray[2] + $aArray[1]) >= $aArray[3]){
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    } else {
        echo "NO\n";
    }
}

<?php
$q = trim(fgets(STDIN));

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

    if ($s % $n <= $b && intval($s / $n) <= $a) {
        $status = true;
    }
   /*if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && $s%$n == 0 && intval($s/$n) <= $a) {
        $status = true;
    } else {
       if ($s % $n <= $b && intval($s / $n) <= $a) {
           $status = true;
       }
   }*/

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

<?php
$q = trim(fgets(STDIN));

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;
    for ($j = 1; $j <= $a; $j ++) {
        $count1 = intval(bcdiv ($s,bcmul($n, $j)));
        $count2 = bcmod ($s,bcmul ($n, $j)) ;
        if ( bccomp($count1, $a) !=1 && bccomp($count2, $b) !=1) {
            $status = true;
            break;
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

<?php
$q = trim(fgets(STDIN));

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

    if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && bcmod($s,$n) == 0 && bcdiv($s,$n) <= $a) {
        $status = true;
    } else {
        for ($j = 1; $j <= $a; $j ++) {
            $count1 = intval(bcdiv ($s, bcmul($n, $j)));
            $count2 = bcmod ($s,bcmul ($n, $j)) ;
            if ( bccomp($count1, $a) !=1 && bccomp($count2, $b) !=1) {
                $status = true;
                break;
            }
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

<?php
$q = trim(fgets(STDIN));

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;
    for ($j = 1; $j <= $a; $j ++) {
        $count1 = intval(bcdiv ($s,bcmul($n, $j)));
        $count2 = bcmod ($s,bcmul ($n, $j)) ;
        if ( $count1 <= $a && $count2  <= $b) {
            $status = true;
            break;
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

<?php
$q = trim(fgets(STDIN));

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;
    for ($j = 0; $j <= $a; $j ++) {
        $count1 = intval(bcdiv ($s,bcmul($n, $j)));
        $count2 = bcmod ($s,bcmul ($n, $j)) ;
        if ( bccomp($count1, $a) !=1 && bccomp($count2, $b) !=1) {
            $status = true;
            break;
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

<?php
$q = trim(fgets(STDIN));

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

    if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && bcmod($s,$n) == 0 && bcdiv($s,$n) <= $a) {
        $status = true;
    } else {
        if ($s % $n <= $b && intval($s / $n) <= $a) {
            $status = true;
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

<?php
$q = trim(fgets(STDIN));

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

   if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && $s%$n == 0 && intval($s/$n) <= $a) {
        $status = true;
    } else {
       if ($s % $n <= $b && intval($s / $n) <= $a) {
           $status = true;
       }
   }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>


<?php
ini_set('register_argc_argv', 1);
ini_set('display_errors', 1);
error_reporting( E_ALL );

if (!isset($argv[1]) && !empty($_SERVER['argv']))
	$argv = $_SERVER['argv'];

$numberOfCafes = 0;

// Beroffice text editor

// user input
$inputString = "";
$inputStringLength = 0;
if (empty($argv) || count($argv) <= 1 ) {
	$handle = fopen ("php://stdin","r");
	$inputString = trim(fgets($handle));
} else {
	$inputString = (int)trim($argv[1]);
}

$inputStringLength = strlen($inputString);
$answer = "-";
if ($inputStringLength > 3000 || $inputStringLength < 1) {
    echo $answer;
} else {
    $stringAsArray = str_split($inputString);
    $vowels = array("a" => "a", "e" => "e", "i" => "i", "o" => "o", "u" => "u", " " => " ");

    $indexOfTypos = array();
	$indexOfAddSpace = array();
    $lastChar = 0;
    $consecutiveConsonants = 0;
	$consecutiveConsonantsArray = array();
    foreach ($stringAsArray as $k => $v) {
        $lastChar = $v;
        if (isset($vowels[$v])) {
			$consecutiveConsonants = 0;
			$consecutiveConsonantsArray = array();
        } else {
            // insert space as late as possible
            if (count($consecutiveConsonantsArray) == 1) {
                if (!isset($consecutiveConsonantsArray[$v]) && $consecutiveConsonants >= 2) {
                    // add space
                    $indexOfAddSpace[$k-1] = $k-1;
                    $consecutiveConsonants = 0;
                    $consecutiveConsonantsArray = array();
                }
            } else if (count($consecutiveConsonantsArray) > 1) {
                $indexOfAddSpace[$k-1] = $k-1;
                $consecutiveConsonants = 0;
                $consecutiveConsonantsArray = array();
            }

			$consecutiveConsonantsArray[$v] = $v;
            $consecutiveConsonants++;
        }
    }

	if(!empty($indexOfAddSpace)) {
		foreach($stringAsArray as $fk => $fv) {
			echo $fv . (isset($indexOfAddSpace[$fk])?" ":"");
		}
	} else {
		echo $inputString;
    }

}

?>

<?php
ini_set('register_argc_argv', 1);
ini_set('display_errors', 1);
error_reporting( E_ALL );

if (!isset($argv[1]) && !empty($_SERVER['argv']))
	$argv = $_SERVER['argv'];

$numberOfCafes = 0;

// Beroffice text editor

// user input
$inputString = "";
$inputStringLength = 0;
if (empty($argv) || count($argv) <= 1 ) {
	$handle = fopen ("php://stdin","r");
	$inputString = trim(fgets($handle));
} else {
	$inputString = (int)trim($argv[1]);
}

$inputStringLength = strlen($inputString);
$answer = "-";
if ($inputStringLength > 3000 || $inputStringLength < 1) {
    echo $answer;
} else {
    $stringAsArray = str_split($inputString);
    $vowels = array("a" => "a", "e" => "e", "i" => "i", "o" => "o", "u" => "u", " " => " ");

    $lastChar = "";
    $consecutiveConsonants = 0;
    $consecutiveSameConsonantsInARow = 0;
    foreach ($stringAsArray as $k => $v) {
        echo $lastChar;

        if (isset($vowels[$v])) {
			$consecutiveConsonants = 0;
            $consecutiveSameConsonantsInARow = 0;
        } else {

            if ($consecutiveConsonants >= 2) {
                if ($consecutiveSameConsonantsInARow == 1 || $lastChar != $v) {
                    echo " ";
                    $consecutiveConsonants = 0;
                    $consecutiveSameConsonantsInARow = 0;
                }
            }

            if ($lastChar == $v)
                $consecutiveSameConsonantsInARow++;
            else
                $consecutiveSameConsonantsInARow = 1;

            $consecutiveConsonants++;
        }

        $lastChar = $v;
    }
    echo $lastChar;

}

?>

<?php
ini_set('register_argc_argv', 1);
ini_set('display_errors', 1);
error_reporting( E_ALL );

if (!isset($argv[1]) && !empty($_SERVER['argv']))
	$argv = $_SERVER['argv'];

$numberOfCafes = 0;

// Beroffice text editor

// user input
$inputString = "";
$inputStringLength = 0;
if (empty($argv) || count($argv) <= 1 ) {
	$handle = fopen ("php://stdin","r");
	$inputString = trim(fgets($handle));
} else {
	$inputString = (int)trim($argv[1]);
}

$inputStringLength = strlen($inputString);
$answer = "-";
if ($inputStringLength > 3000 || $inputStringLength < 1) {
    echo $answer;
} else {
    $stringAsArray = str_split($inputString);
//    $binaryInterpretation = array(); // do I need this at all?
    $vowels = array("a" => "a", "e" => "e", "i" => "i", "o" => "o", "u" => "u", " " => " ");
    /*
     * create $binaryInterpretation
     * 1 - for vowels
     * 2 - for consonants
     * 3 - for space
     */

    $indexOfTypos = array();
	$indexOfAddSpace = array();
    $lastCharType = 0;
    $lastChar = 0;
    $consecutiveConsonants = 0;
	$consecutiveConsonantsArray = array();
    foreach ($stringAsArray as $k => $v) {
        $lastChar = $v;
        $code = 2;
        if (isset($vowels[$v])) {
            $code = 1;
            if($v==" "){
                $code = 3;
            }
			$consecutiveConsonants = 0;
			$consecutiveConsonantsArray = array();
        } else {
			if ($consecutiveConsonants==2) {

				if(count($consecutiveConsonantsArray) == 1) {
					if(!isset($consecutiveConsonantsArray[$v])){
						// add space
						$indexOfAddSpace[$k-1] = $k-1;
						$consecutiveConsonants = 0;
						$consecutiveConsonantsArray = array();
					}
				} else {
					$indexOfAddSpace[$k-1] = $k-1;
					$consecutiveConsonants = 0;
					$consecutiveConsonantsArray = array();
				}

			}
			$consecutiveConsonantsArray[$v] = $v;
            $consecutiveConsonants++;
        }
//        $binaryInterpretation[$k] = $code;
        $lastCharType = $code;
    }

	if(!empty($indexOfAddSpace)) {
		foreach($stringAsArray as $fk => $fv) {
			echo $fv . (isset($indexOfAddSpace[$fk])?" ":"");
		}
	} else {
		echo $inputString;
    }

}

?>

<?php
ini_set('register_argc_argv', 1);
ini_set('display_errors', 1);
error_reporting( E_ALL );

if (!isset($argv[1]) && !empty($_SERVER['argv']))
	$argv = $_SERVER['argv'];

$numberOfCafes = 0;

// Beroffice text editor

// user input
$inputString = "";
$inputStringLength = 0;
if (empty($argv) || count($argv) <= 1 ) {
	$handle = fopen ("php://stdin","r");
	$inputString = trim(fgets($handle));
} else {
	$inputString = (int)trim($argv[1]);
}

$inputStringLength = strlen($inputString);
$answer = "-";
if ($inputStringLength > 3000 || $inputStringLength < 1) {
    echo $answer;
} else {
    $stringAsArray = str_split($inputString);
    $binaryInterpretation = array(); // do I need this at all?
    $vowels = array("a" => "a", "e" => "e", "i" => "i", "0" => "o", " " => " ");
    /*
     * create $binaryInterpretation
     * 1 - for vowels
     * 2 - for consonants
     * 3 - for space
     */

    $indexOfTypos = array();
	$indexOfAddSpace = array();
    $lastCharType = 0;
    $lastChar = 0;
    $consecutiveConsonants = 0;
	$consecutiveConsonantsArray = array();
    foreach ($stringAsArray as $k => $v) {
        $lastChar = $v;
        $code = 2;
        if (isset($vowels[$v])) {
            $code = 1;
            if($v==" "){
                $code = 3;
            }
			$consecutiveConsonants = 0;
			$consecutiveConsonantsArray = array();
        } else {
			if ($consecutiveConsonants==2) {

				if(count($consecutiveConsonantsArray) == 1) {
					if(!isset($consecutiveConsonantsArray[$v])){
						// add space
						$indexOfAddSpace[$k-1] = $k-1;
						$consecutiveConsonants = 0;
						$consecutiveConsonantsArray = array();
					}
				} else {
					$indexOfAddSpace[$k-1] = $k-1;
					$consecutiveConsonants = 0;
					$consecutiveConsonantsArray = array();
				}

			}
			$consecutiveConsonantsArray[$v] = $v;
            $consecutiveConsonants++;
        }
        $binaryInterpretation[$k] = $code;
        $lastCharType = $code;
    }

	if(!empty($indexOfAddSpace)) {
		foreach($stringAsArray as $fk => $fv) {
			echo $fv . (isset($indexOfAddSpace[$fk])?" ":"");
		}
	} else {
		echo $inputString;
    }
}

?>


<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       if (in_array($x, $ar)) {
            echo "1\n";
        } else {
            $max = max($ar);
            if($x < $max) {
                $n = 2;
            } else {
                $n = ceil($x / $max);
            }
             echo $n ."\n";
        }

    }

<?php
list($m) = explode(' ', trim(fgets(STDIN)));
for($k = 0; $k < $m; $k++) {
    list($a,$b) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iAnswer = 0;
    $bFlag = false;
    $aTest = [];
    foreach ($aArray as $sK => $sV) {
        $aTest[] = $sV;
    }
    foreach ($aTest as $sK => $sV) {
        if ($sV == $b) {
            $iAnswer = 1;
            $bFlag = true;
            break;
        }
    }
    if (!$bFlag) {
        $iAnswer = max($aTest);
        if ($b < $iAnswer) {
            $iAnswer = 2;
            $bFlag = true;
        }
    }
    if ($bFlag) {
        echo $iAnswer ."\n";
    } else {
        echo ceil($b/$iAnswer) ."\n";
    }
}

<?php
list($m) = explode(' ', trim(fgets(STDIN)));
for($k = 0; $k < $m; $k++) {
    list($a,$b) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iAnswer = 0;
    $bFlag = false;
    $aTest = [];
    foreach ($aArray as $sK => $sV) {
        $aTest[] = $sV;
    }
    foreach ($aTest as $sK => $sV) {
        if ($sK == $b) {
            $iAnswer = 1;
            $bFlag = true;
            break;
        }
    }
    $iAnswer = max($aTest);
    if ($b < $iAnswer) {
        $iAnswer = 2;
        $bFlag = true;
    }
    if ($bFlag) {
        echo $iAnswer ."\n";
    } else {
        echo ceil($b/$iAnswer) ."\n";
    }
}

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
       arsort($ar);
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($count == $x) {
                 $n = $j+1;
                    break;
            }
            if($count > $x) {
                if($j == 0 ){
                    $j++;
                }
                 $n = $j+1;
                    break;
            }
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo  $n."\n";
        } else {
            $s = $x - $count;
            if($s < $max) {
                $n = $n + 2;
            }elseif($s == $max) {
               $n = $n + 1;
            } else {
                $n1 = ceil($s / $max);
                $n = $n + $n1;
            }
             echo $n ."\n";

        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($count == $x) {
                 $n = $j+1;
                    break;
            }
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo  $n."\n";
        } else {
            $s = $x - $count;

            $n1 =ceil($s / $max);
            echo $n + $n1."\n";
        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
       if (in_array($x, $ar)) {
            echo "1\n";
        } else {
            arsort($ar);
            for($j=0; $j<$n; $j++) {
                 $count +=$ar[$j];
                 if($count == $x) {
                     $n = $j+1;
                        break;
                }
                if($count > $x) {
                    if($j == 0 ){
                        $j++;
                    }
                     $n = $j+1;
                        break;
                }
                 if($ar[$j] > $max) {
                     $max = $ar[$j];
                 }
            }

            if($count >= $x) {
                echo  $n."\n";
            } else {
                $s = $x - $count;
                if($s < $max) {
                    $n = $n + 2;
                }elseif($s == $max) {
                   $n = $n + 1;
                } else {
                    $n1 = ceil($s / $max);
                    $n = $n + $n1;
                }
                 echo $n ."\n";

            }
        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
       arsort($ar);
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($count >= $x) {
                 $n = $j+1;
                    break;
            }
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo  $n."\n";
        } else {
            $s = $x - $count;
            if($s < $max) {
                $n = $n + 2;
            }elseif($s == $max) {
               $n = $n + 1;
            } else {
                $n1 = ceil($s / $max);
                $n = $n + $n1;
            }
             echo $n ."\n";

        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo $n."\n";
        } else {
            $s = $x - $count;

            $n1 =ceil($s / $max);
            echo $n + $n1."\n";
        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($count == $x) {
                 $n = $j+1;
                    break;
            }
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo  $n."\n";
        } else {
            $s = $x - $count;
            if($s < $max) {
                $n = $n + 2;
            }elseif($s == $max) {
               $n = $n + 1;
            } else {
                $n1 = ceil($s / $max);
                $n = $n + $n1;
            }
             echo $n ."\n";

        }

    }


<?php

list($ncups, $nholes, $nswaps) = explode(" ", trim(fgets(STDIN)));
$holes = explode(" ", trim(fgets(STDIN)));

$hh = array();
foreach($holes as $hole)
{
	$hh[$hole] = true;
}

if(@isset($hh[1]) && $hh[1]) {
	$nswaps = 0;
}

$pos = 1;

for($i = 0; $i < $nswaps; $i++)
{

	list($f, $t) = explode(" ", trim(fgets(STDIN)));

	if($f != $pos && $t != $pos)
		continue;

	$pos = ($pos == $t) ? $f : $t;

	if(@isset($hh[$pos]) && $hh[$pos])
		break;
}

echo $pos . PHP_EOL;

<?php
list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = array();
for($x = 0; $x < $b; $x++)
{
     $e[$d[$x]] = 1;
}
$f = 1;
if($e[$f] == TRUE)
{
     print "1";
}
else
{
     for($x = 1; $x <= $c; $x++)
     {
          list($g, $h) = explode(" ", trim(fgets(STDIN)));
          if($g == $f)
          {
               $f = $h;
               if($e[$f] == TRUE)
               {
                    break;
               }
          }
          elseif($h == $f)
          {
               $f = $g;
               if($e[$f] == TRUE)
               {
                    break;
               }
          }
     }
     print $f;
}
?>

<?php
list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = array();
for($x = 0; $x < $b; $x++)
{
     $e[$d[$x]] = 1;
}
$f = 1;
if($e[$f] == TRUE)
{
     print "1";
}
else
{
     for($x = 1; $x <= $c; $x++)
     {
          list($g, $h) = explode(" ", trim(fgets(STDIN)));
          if($g == $f)
          {
               $f = $h;
               if($e[$f] == TRUE)
               {
                    break;
               }
          }
     }
     print $f;
}
?>

<?php

list($ncups, $nholes, $nswaps) = explode(" ", trim(fgets(STDIN)));
$holes = explode(" ", trim(fgets(STDIN)));

$pos = 1;

for($i = 0; $i < $nswaps; $i++)
{
	if(in_array($pos, $holes))
		break;

	list($f, $t) = explode(" ", trim(fgets(STDIN)));

	if($f != $pos)
		continue;

	$pos = $t;

}

echo $pos . PHP_EOL;

<?php

list($ncups, $nholes, $nswaps) = explode(" ", trim(fgets(STDIN)));
$holes = explode(" ", trim(fgets(STDIN)));

$pos = 1;

for($i = 0; $i < $nswaps; $i++)
{
	list($f, $t) = explode(" ", trim(fgets(STDIN)));

	if($f != $pos)
		continue;

	$pos = $t;

	if(in_array($pos, $holes))
		break;
}

echo $pos . PHP_EOL;


<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
rsort($c);
sort($d);
if($c[0] < $d[0])
{
    if(($c[count($c) - 1] * 2) < $d[0])
    {
        print max($c[count($c) - 1] * 2, $c[0]);
    }
    else
    {
        print "-1";
    }
}
else
{
    print "-1";
}
?>

<?php

list($n, $m) = explode(' ', getline());

$n = intval($n);
$m = intval($m);

$a = explode(' ', getline());
$b = explode(' ', getline());

init_array($a, $n);
init_array($b, $m);

$lower = max($a);
$upper = min($b);

$answer = -1;

while ($lower < $upper) {
  $extra = false;
  for ($i = 0; $i < $n; $i ++) {
    if ($a[$i] *2 <= $lower) {
      $extra = true;
      break;
    }
  }
  if ($extra) {
    $answer = $lower;
    break;
  }
  $lower ++;
}

print $answer;

function init_array(&$array, $size) {
  for ($i = 0; $i < $size; $i ++) {
    $array[$i] = intval($array[$i]);
  }
}

function getline() {
  return trim(fgets(STDIN));
}

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $c;
rsort($e);
$f = $d;
sort($f);
if($e[0] < $f[0])
{
    if(($e[count($e) - 1] * 2) <= $e[0])
    {
        print $e[0];
    }
    else
    {
        print "-1";
    }
}
else
{
    print "-1";
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $c;
rsort($e);
$f = $d;
sort($f);
if($a == "1")
{
    print "-1";
}
else
{
    if($e[0] < $f[0])
    {
        if(($e[count($e) - 1] * 2) <= $e[0])
        {
            print $e[0];
        }
        else
        {
            print "-1";
        }
    }
    else
    {
        print "-1";
    }
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $c;
rsort($e);
$f = $d;
sort($f);
if($e[0] < $f[0])
{
    if($a == "1")
    {
        $g = $c[0] * 2;
        if($g < $f[count($f) - 1])
        {
            print $g;
        }
        else
        {
            print "-1";
        }
    }
    elseif(($e[count($e) - 1] * 2) <= $e[0])
    {
        print $e[0];
    }
    else
    {
        print "-1";
    }
}
else
{
    print "-1";
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $c;
rsort($e);
$f = $d;
sort($f);
$h = array_unique($c);
if($e[0] < $f[0])
{
    if(($a == "1") || (count($h) == "1"))
    {
        $g = $c[0] * 2;
        if($g < $f[count($f) - 1])
        {
            print $g;
        }
        else
        {
            print "-1";
        }
    }
    elseif(($e[count($e) - 1] * 2) <= $e[0])
    {
        print $e[0];
    }
    else
    {
        print "-1";
    }
}
else
{
    print "-1";
}
?>

<?php

list($n,$m) = explode(" ",trim(fgets(STDIN)));
$V = explode(" ",trim(fgets(STDIN)));
$B = explode(" ",trim(fgets(STDIN)));

$p0 = min($V);
$p1 = max($V);
$p2 = min($B);

if (2*$p0<$p2){
	if ($p1 > 2*$p0){
		echo $p1;
	} else {
		echo (2*$p0);
	}
} else {
	echo "-1";
}

?>


<?php
$a = trim(fgets(STDIN));
$b = str_split(trim(fgets(STDIN)));
$c = array_unique($b);
if((count($c) == 1) || ($a == 2))
{
    print "0";
}
else
{
    for($x = 0; $x < $a; $x++)
    {
        if($b[0] != $b[$a - 1])
        {
            array_unshift($b, $b[$a - 1]);
            unset($b[$a]);
        }
        else
        {
            break;
        }
    }
    $d = array();
    $e = array();
    for($x = 0; $x < $a; $x++)
    {
        if($b[$x] == "H")
        {
            array_push($d, $x + 1);
        }
        else
        {
            array_push($e, $x + 1);
        }
    }
    $h = array();
    for($x = 1; $x <= $a - count($d) + 1; $x++)
    {
        $f = range($x, count($d) + $x - 1);
        $g = array_intersect($d, $f);
        array_push($h, count($g));
    }
    $k = array();
    for($x = 1; $x <= $a - count($e) + 1; $x++)
    {
        $i = range($x, count($e) + $x - 1);
        $j = array_diff($e, $i);
        array_push($k, count($j));
    }
    sort($h);
    sort($k);
    print min($h[0], $k[0]);
}
?>

<?php
$a = trim(fgets(STDIN));
$b = str_split(trim(fgets(STDIN)));
$c = array_unique($b);
if((count($c) == 1) || ($a == 2))
{
    print "0";
}
else
{
    for($x = 0; $x < $a; $x++)
    {
        if($b[0] != $b[$a - 1])
        {
            array_unshift($b, $b[$a - 1]);
            unset($b[$a]);
        }
        else
        {
            break;
        }
    }
    $d = array();
    $e = array();
    for($x = 0; $x < $a; $x++)
    {
        if($b[$x] == "H")
        {
            array_push($d, $x + 1);
        }
        else
        {
            array_push($e, $x + 1);
        }
    }
    $h = array();
    for($x = 1; $x <= $a - count($d) + 1; $x++)
    {
        $f = range($x, count($d) + $x - 1);
        $g = array_intersect($d, $f);
        array_push($h, count($g));
    }
    $k = array();
    for($x = 1; $x <= $a - count($e) + 1; $x++)
    {
        $i = range($x, count($e) + $x - 1);
        $j = array_intersect($e, $i);
        array_push($k, count($j));
    }
    sort($h);
    sort($k);
    print min($h[0], $k[0]);
}
?>

<?php
$a = trim(fgets(STDIN));
$b = str_split(trim(fgets(STDIN)));
$c = array_unique($b);
if((count($c) == 1) || ($a == 2))
{
    print "0";
}
else
{
    $d = array();
    $e = array();
    for($x = 0; $x < $a; $x++)
    {
        if($b[$x] == "H")
        {
            array_push($d, $x + 1);
        }
        else
        {
            array_push($e, $x + 1);
        }
    }
    if(count($d) <= count($e))
    {
        $h = array();
        for($x = 1; $x <= $a - count($d) + 1; $x++)
        {
            $f = range($x, count($d) + $x - 1);
            $g = array_diff($d, $f);
            array_push($h, count($g));
        }
        sort($h);
        print $h[0];
    }
    else
    {
        $k = array();
        for($x = 1; $x <= $a - count($e) + 1; $x++)
        {
            $i = range($x, count($e) + $x - 1);
            $j = array_diff($e, $i);
            array_push($k, count($j));
        }
        sort($k);
        print $k[0];
    }
}
?>