<?php
$no = 'NO';
$yes = 'YES';
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647
$alph = 'abcdefghijklmnopqrstuvwxyz';
$inter = "\n";
define("INTMAXVALUE",     2147483646);

   $t = IO::getInt();
//   $point = ord('a') + ord('b') ;

   for($q=0; $q <$t; $q++) {
       $ans = 0;
       $n = IO::getInt();
       $a = IO::getArray();
       $m = IO::getInt();
       $b = IO::getArray();

     //   $bSum = array_sum($b);
     $index = 1;
       for($i = 0; $i <$m; $i++) {
          $index = $index + $b[$i] > $n ? $index + $b[$i] - $n :  $index + $b[$i];
       }

        IO::pr($a[$index-1]);
   }

 class IO {
      public static function getInt()
      {
          return trim(fgets(STDIN));
      }

     public static function getArray()
     {
         return explode(' ', trim(fgets(STDIN)));
     }
     public static function pr($s)
     {
         if(is_array($s)) {
             echo implode( ' ', $s), PHP_EOL;
         } else {
             echo $s, PHP_EOL;
         }
     }
     public static function getMinValue($x, $y) {
         return $x > $y ? $y : $x;
     }
     public static function getMaxValue($x, $y) {
         return $x > $y ? $x : $y;
     }
 }

 class Algor {
    public static function isPrime($n) {
         $d = 2;
         while ($n % $d != 0) {
         $d += 1;
         }

        return $d == $n;
    }

     public static function fabicon($n, $a) {
         if($n <= 1) {
             return $a[$n];
         }
         for($i=2; $i<=$n; $i++) {
             $a[$i] = $a[$i-1] + $a[$i-2];
         }

         return $a[$n];
     }

     function getRotate($a, $s, $e, $ind) {
         $ar = [];
         for ($i= $s; $i<=$e; $i++) {
             $ar[$i] = $a[$i];
             $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;
             // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , "\n";
             $a[$i] = $j < $i ? $ar[$j] : $a[$j];
         }
         return $a;
     }

}

class bigOperation {
    public static function  isBigNumber($n)
    {
        return bccomp($n, INTMAXVALUE) == 1;
    }
    // bcadd — Сложить 2 числа произвольной точности
    public static function  bcAdd($x, $y)
    {
        return bcadd($x, $y);
    }
// bccomp — Сравнение двух чисел произвольной точности
//return 1 if x>y, 0= x==y, -1 x < y
    public static function  bcComp($x, $y)
    {
        return bccomp($x, $y);
    }
// bcdiv — Операция деления для чисел произвольной точности
    public static function  bcDiv($x, $y)
    {
        return bcdiv($x, $y);
    }
// bcmod — Получает остаток от деления чисел с произвольной точностью
    public static function  bcMod($x, $y)
    {
        return bcmod($x, $y);
    }
// bcmul — Умножение двух чисел с произвольной точностью
    public static function  bcMul($x, $y)
    {
        return bcmul($x, $y);
    }
// bcpow — Возведение в степень чисел с произвольной точностью
    public static function  bcPow($x, $y)
    {
        return bcpow($x, $y);
    }
// bcpowmod — Возводит одно число в степень другого и возвращает остаток от деления результата на третье число
// bcscale — Задает количество чисел после десятичной точки по умолчанию для всех bc math функций.
// bcsqrt — Извлекает квадратный корень из числа с произвольной точностью
    public static function  bcSqrt($x, $y)
    {
        return bcsqrt($x, $y);
    }
// bcsub — Вычитает одно число с произвольной точностью из другого
    public static function  bcSub($x, $y)
    {
        return bcsub($x, $y);
    }
    public static function getMaxValue($x, $y) {
        return bccomp($x, $y) == 1 ? $x : $y;
    }
    public static function getMinValue($x, $y) {
        return bccomp($x, $y) == 1 ? $y : $x;
    }

    public static function getDareje($n, $k) {
        if($k == 0) {
            return 1;
        }
        return bcmul($n, self::getDareje($n, $k-1));
    }
}

class Sorting
{
    public static function mergeSort($aArray) {
        if(count($aArray) <= 1) {
            return $aArray;
        }
        $aLeft = [];
        $aRight = [];
        $n =floor(count($aArray) / 2);
        for($i = 0; $i <$n; $i++) {
            $aLeft[] = $aArray[$i];
        }
        for($i = $n; $i <count($aArray); $i++) {
            $aRight[] = $aArray[$i];
        }

        return self::merge(self::mergeSort($aLeft), self::mergeSort($aRight));
    }

    public static function merge($aLeft, $aRight) {
        $aResult = [];
        $iL = 0;
        $iR = 0;

        while($iL < count($aLeft) && $iR < count($aRight)) {
            if($aLeft[$iL] <= $aRight[$iR]) {
                $aResult[] = $aLeft[$iL];
                $iL++;
            } else {
                $aResult[] = $aRight[$iR];
                $iR++;
            }
        }

        while($iL < count($aLeft)) {
            $aResult[] = $aLeft[$iL];
            $iL++;
        }
        while($iR < count($aRight)) {
            $aResult[] = $aRight[$iR];
            $iR++;
        }

        return $aResult;

    }
}

class SolveArchive
{

}

<?php
    $t = trim(fgets(STDIN));
    for($t1 = 1; $t1 <= $t; $t1++) {
        $n = trim(fgets(STDIN));
        $a = explode(' ', trim(fgets(STDIN)));

        $m = trim(fgets(STDIN));
        $b = explode(' ', trim(fgets(STDIN)));

        $sSum = 0;
        for ($i=0; $i<$m; $i++) {
            $sSum = bcadd($sSum, $b[$i]);
        }

        $iIndex = bcmod($sSum, $n);
        echo $a[$iIndex] . PHP_EOL;
    }
?>

<?php

function run(){
    $n = trim(fgets(STDIN));
    $arr = explode(' ', trim(fgets(STDIN)));
    $m = trim(fgets(STDIN));
    $brr = explode(' ', trim(fgets(STDIN)));
    $sum = 0;
    foreach($brr as $e){
             $sum += $e;
             $sum %= $n;
    }
    $sum %= $n;
    echo "$arr[$sum]\n";
}

$test_cases = trim(fgets(STDIN));
while($test_cases--){
    run();
}
?>

<?php
    $t = trim(fgets(STDIN));
    for($t1 = 1; $t1 <= $t; $t1++) {
        $n = trim(fgets(STDIN));
        $a = explode(' ', trim(fgets(STDIN)));
        $b = explode(' ', trim(fgets(STDIN)));

        $iLeft = 0;
        $iRight = 0;
        $aCheck = [];
        for ($i = 0; $i < $n; $i++) {
            for ($j = $i+1; $j < $n; $j++) {
                if ($a[$i] > $a[$j]) {
                    $iRight++;
                    $sA = $a[$j];

                    $a[$j] = $a[$i];
                    $a[$i] = $sA;

                    $sB = $b[$j];

                    $b[$j] = $b[$i];
                    $b[$i] = $sB;

                    $i1 = $j+1;
                    $i2 = $i+1;

                    $aCheck[] = "$i1 $i2";

                    if ($b[$i] > $b[$j]) {
                        $iLeft++;
                    }
                }

            }
        }

        //echo $iRight . PHP_EOL;
        //echo $iLeft;
        //exit;

        if ($iRight > 0 &&  $iLeft == 0) {
            echo $iRight . PHP_EOL;
            foreach ($aCheck as $sVal) {
                echo $sVal . PHP_EOL;
            }
        } else if ($iRight == 0 && $iLeft == 0){
            echo 0 . PHP_EOL;
        } else {
            echo -1 . PHP_EOL;
        }
    }
?>

<?php
    $t = trim(fgets(STDIN));
    for($t1 = 1; $t1 <= $t; $t1++) {
        $n = trim(fgets(STDIN));
        $a = explode(' ', trim(fgets(STDIN)));

        $m = trim(fgets(STDIN));
        $b = explode(' ', trim(fgets(STDIN)));

        $iIndex = array_sum($b) % $n;
        echo $a[$iIndex] . PHP_EOL;
    }
?>

<?php
    $t = trim(fgets(STDIN));
    for($t1 = 1; $t1 <= $t; $t1++) {
        $n = trim(fgets(STDIN));
        $sA = $sA = str_replace(' ', '', trim(fgets(STDIN)));

        $m = trim(fgets(STDIN));
        $b = explode(' ', trim(fgets(STDIN)));

        for ($j=0; $j<$m; $j++) {
            $sNew = '';
            $countM = $b[$j];

            $sNew1 = substr($sA, $countM);
            $sNew2 = substr($sA, 0, $countM);
            $sNew = $sNew1 . $sNew2;

            $sA = $sNew;
        }
        echo $sNew[0] . PHP_EOL;

    }
?>

<?php

function run(){
    $n = trim(fgets(STDIN));
    $arr = explode(' ', trim(fgets(STDIN)));
    $m = trim(fgets(STDIN));
    $brr = explode(' ', trim(fgets(STDIN)));
    $sum = 0;
    foreach($brr as $e){
             $sum += $e;
    }
    $sum %= $n;
    echo "$arr[$sum]\n";
}

$test_cases = trim(fgets(STDIN));
while($test_cases--){
    run();
}
?>

<?php
$no = 'NO';
$yes = 'YES';
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647
$alph = 'abcdefghijklmnopqrstuvwxyz';
$inter = "\n";
define("INTMAXVALUE",     2147483646);

   $t = IO::getInt();
//   $point = ord('a') + ord('b') ;

   for($q=0; $q <$t; $q++) {
       $ans = 0;
       $n = IO::getInt();
       $a = IO::getArray();
       $m = IO::getInt();
       $b = IO::getArray();

       $bSum = array_sum($b);
     //   $s = floor($bSum/$n);
       $index = $bSum%$n;
     //   IO::pr($index);

        IO::pr($a[$index]);
   }

 class IO {
      public static function getInt()
      {
          return trim(fgets(STDIN));
      }

     public static function getArray()
     {
         return explode(' ', trim(fgets(STDIN)));
     }
     public static function pr($s)
     {
         if(is_array($s)) {
             echo implode( ' ', $s), PHP_EOL;
         } else {
             echo $s, PHP_EOL;
         }
     }
     public static function getMinValue($x, $y) {
         return $x > $y ? $y : $x;
     }
     public static function getMaxValue($x, $y) {
         return $x > $y ? $x : $y;
     }
 }

 class Algor {
    public static function isPrime($n) {
         $d = 2;
         while ($n % $d != 0) {
         $d += 1;
         }

        return $d == $n;
    }

     public static function fabicon($n, $a) {
         if($n <= 1) {
             return $a[$n];
         }
         for($i=2; $i<=$n; $i++) {
             $a[$i] = $a[$i-1] + $a[$i-2];
         }

         return $a[$n];
     }

     function getRotate($a, $s, $e, $ind) {
         $ar = [];
         for ($i= $s; $i<=$e; $i++) {
             $ar[$i] = $a[$i];
             $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;
             // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , "\n";
             $a[$i] = $j < $i ? $ar[$j] : $a[$j];
         }
         return $a;
     }

}

class bigOperation {
    public static function  isBigNumber($n)
    {
        return bccomp($n, INTMAXVALUE) == 1;
    }
    // bcadd — Сложить 2 числа произвольной точности
    public static function  bcAdd($x, $y)
    {
        return bcadd($x, $y);
    }
// bccomp — Сравнение двух чисел произвольной точности
//return 1 if x>y, 0= x==y, -1 x < y
    public static function  bcComp($x, $y)
    {
        return bccomp($x, $y);
    }
// bcdiv — Операция деления для чисел произвольной точности
    public static function  bcDiv($x, $y)
    {
        return bcdiv($x, $y);
    }
// bcmod — Получает остаток от деления чисел с произвольной точностью
    public static function  bcMod($x, $y)
    {
        return bcmod($x, $y);
    }
// bcmul — Умножение двух чисел с произвольной точностью
    public static function  bcMul($x, $y)
    {
        return bcmul($x, $y);
    }
// bcpow — Возведение в степень чисел с произвольной точностью
    public static function  bcPow($x, $y)
    {
        return bcpow($x, $y);
    }
// bcpowmod — Возводит одно число в степень другого и возвращает остаток от деления результата на третье число
// bcscale — Задает количество чисел после десятичной точки по умолчанию для всех bc math функций.
// bcsqrt — Извлекает квадратный корень из числа с произвольной точностью
    public static function  bcSqrt($x, $y)
    {
        return bcsqrt($x, $y);
    }
// bcsub — Вычитает одно число с произвольной точностью из другого
    public static function  bcSub($x, $y)
    {
        return bcsub($x, $y);
    }
    public static function getMaxValue($x, $y) {
        return bccomp($x, $y) == 1 ? $x : $y;
    }
    public static function getMinValue($x, $y) {
        return bccomp($x, $y) == 1 ? $y : $x;
    }

    public static function getDareje($n, $k) {
        if($k == 0) {
            return 1;
        }
        return bcmul($n, self::getDareje($n, $k-1));
    }
}

class Sorting
{
    public static function mergeSort($aArray) {
        if(count($aArray) <= 1) {
            return $aArray;
        }
        $aLeft = [];
        $aRight = [];
        $n =floor(count($aArray) / 2);
        for($i = 0; $i <$n; $i++) {
            $aLeft[] = $aArray[$i];
        }
        for($i = $n; $i <count($aArray); $i++) {
            $aRight[] = $aArray[$i];
        }

        return self::merge(self::mergeSort($aLeft), self::mergeSort($aRight));
    }

    public static function merge($aLeft, $aRight) {
        $aResult = [];
        $iL = 0;
        $iR = 0;

        while($iL < count($aLeft) && $iR < count($aRight)) {
            if($aLeft[$iL] <= $aRight[$iR]) {
                $aResult[] = $aLeft[$iL];
                $iL++;
            } else {
                $aResult[] = $aRight[$iR];
                $iR++;
            }
        }

        while($iL < count($aLeft)) {
            $aResult[] = $aLeft[$iL];
            $iL++;
        }
        while($iR < count($aRight)) {
            $aResult[] = $aRight[$iR];
            $iR++;
        }

        return $aResult;

    }
}

class SolveArchive
{

}


<?php
$a = trim(fgets(STDIN));
$d = array();
$e = 0;
$g = array();
$h = 1;
for($x = 1; $x <= $a; $x++)
{
    list($b, $c) = explode(" ", trim(fgets(STDIN)));
    $d[$e] = $b . $h;
    $g[$e] = "1";
    $e++;
    $h++;
    $d[$e] = $c . $h;
    $g[$e] = "2";
    $e++;
    $h++;
}
asort($d);
$i = array_keys($d);
sort($d);
$j = array_combine($i, $g);
ksort($j);
$l = array_slice($j, 0, $a);
sort($l);
$m = array_unique($l);
$n = array_keys($m);
$o = $n[1];
$p = count($l) - $n[1];
$r = max(floor($a / 2), $o);
$s = max(floor($a / 2), $p);
print implode("", array_fill(0, $r, "1"));
print implode("", array_fill(0, $a - $r, "0")) . "\n";
print implode("", array_fill(0, $s, "1"));
print implode("", array_fill(0, $a - $s, "0"));
?>


<?php

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

function readInt() {
  return (int) read() ;
}

function readStrs() {
  return explode(" ",read()) ;
}

function readIntArray() {
  return array_map('intval', readStrs());
}

function readAsArray() {
  return str_split(read()) ;
}

function printLine($arg) {
  if($arg === false) {
    print_r("false") ;
  }
  elseif($arg === true) {
    print_r("true") ;
  }
  else {
    print_r($arg) ;
  }
  print_r("\n") ;
}

$t = readInt() ;
$ans = [] ;
while($t--) {
	[$n,$c,$k] = readIntArray() ;
	$st = read() ;
	$dic = array([1,$n,0]) ;
	for ($i=0; $i < $c; $i++) {
		[$l,$r] = readIntArray() ;
		$dic[] = array($dic[$i][1]+1,$dic[$i][1]+($r-$l+1),$dic[$i][1]+1-$l);
	}
	// printLine($dic);
	while($k--){
		$srs = readInt() ;
		for($i=$c;$i>-1;$i--) {
			if($srs >= $dic[$i][0]) {
				$srs -= $dic[$i][2] ;
			}
		}
		$ans[] = ($st[$srs-1]) ;
	}
}
printLine(implode("\n",$ans));

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
//101
//101
//001
function solve()
{
    list($n, $c, $q) = IO::getArray();
    $s = IO::get();
    $a = [];

    $ans = 0;

    $ll = [];
    $rr = [];
    $len = [];
    $len[] = $n;
     for($i=0; $i<$c; $i++) {
          list($l, $r) = IO::getArray();
        $ll[$i] = $l;
        $rr[$i] = $r;
         $len[] = $len[$i] + $r-$l+1;
     }

     for($i=0; $i<$q; $i++) {
          $k = IO::get();
          for ($j = $c - 1; $j >= 0; $j--) {
             if ($k > $len[$j]) {
               $k = $ll[$j] + ($k - $len[$j] - 1);
               if($k <= $n) {
                    break;
               }
             }
          }
          IO::pr($s[$k-1]);
     }

//    IO::pr($ans);

}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}


<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
sort($c);
sort($d);
$e = 0;
for($x = count($c) - 1, $y = count($d) - 1; $x >= 0, $y >= 0; $x--, $y--)
{
    if($c[$x] <= $d[$y])
    {
        $e++;
    }
    else
    {
        array_splice($d, 0, 1);
    }
    if($x == 0)
    {
        break;
    }
}
print count($c) - $e;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
sort($c);
sort($d);
$e = 0;
$f = count($d);
for($x = count($c) - 1, $y = $f - 1; $x >= 0, $y >= 0; $x--, $y--)
{
    if($c[$x] <= $d[$y])
    {
        $e++;
    }
    else
    {
        array_splice($d, 0, 1);
    }
    if(($x == 0) || ($y == 0))
    {
        break;
    }
}
print count($c) - $e;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
rsort($c);
rsort($d);
$e = 0;
for($x = 0; $x < count($c); $x++)
{
    if($c[$x] <= $d[$x])
    {
        $e++;
    }
}
print count($c) - $e;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
sort($c);
sort($d);
$e = 0;
for($x = count($c) - 1, $y = count($d) - 1; $x >= 0, $y >= 0; $x--, $y--)
{
    if($c[$x] <= $d[$y])
    {
        $e++;
    }
    else
    {
        array_splice($d, 0, 1);
    }
    if(($x == 0) && ($y == 0))
    {
        break;
    }
}
print count($c) - $e;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
sort($c);
sort($d);
$e = 0;
for($x = count($c) - 1, $y = count($d) - 1; $x >= 0, $y >= 0; $x--, $y--)
{
    if($c[$x] <= $d[$y])
    {
        $e++;
    }
    else
    {
        array_splice($d, 0, 1);
    }
    if(($x == 0) || ($y == 0))
    {
        break;
    }
}
print count($c) - $e;
?>


<?php
list($n) = explode(' ', trim(fgets(STDIN)));
for($j = 0; $j < $n; $j++) {
    list($a, $b, $c) = explode(' ', trim(fgets(STDIN)));
    $iMin = abs($a - $b) + abs($a - $c) + abs($b - $c);
    if ($iMin > 4) {
        $iMin = $iMin - 4;
    } else {
        $iMin = 0;
    }
    echo $iMin . "\n";
}


<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = trim(fgets(STDIN));
$d = array();
for($x = 0; $x < $a; $x++)
{
     $d[$c[$x]]++;
}
if(count($d) < $b)
{
     print "0";
}
else
{
     print (min($d) * count($d));
}
?>

<?php
fscanf(STDIN,"%d %d",$len,$k);
$str=trim(fgets(STDIN));
$alp="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str1="";
for ($i=0; $i <strlen($alp) ; $i++)
{
	for ($j=0; $j <$len; $j++)
	{
		if($alp[$i]==$str[$j])
		{
			$str1.=$alp[$i];
			break;
		}

	}
}
$len1=strlen($str1);
if($len1!=$k)
  	echo "0";
else
 {
		for ($i=0; $i <strlen($str1) ; $i++)
	    {
		   $count=0;

			for ($j=0; $j <$len; $j++)
			{
				if($str1[$i]==$str[$j])
				{

					$count++;
				}

			}
			$occurrence[$i]=$count;
	    }
	    $min=$occurrence[0];
	    for ($i=0; $i <count($occurrence) ; $i++)
	    {
	    	if($occurrence[$i]<$min)
	    		$min=$occurrence[$i];
	    }
	    echo $min*$len1;
 }


<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));
for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));
  $a = explode(" ", trim(fgets($file)));

  $result = array_count_values($a);
  rsort($result);
  echo $result[0].PHP_EOL;
}
?>

<?php

$n = readline();

while ($n--) {
    $m = readline();
    $nums = explode(' ', readline());
    $cnt = 1;
    $mid = intdiv(count($nums), 2);
//    echo $del; exit;
    if (count($nums) == 1){
        $res[] = 1; continue;
    }

    $max = -1;
    for ($i = 0; $i < count($nums)-1; $i++) {
        if ($nums[$i] == $nums[$i+1]) {
            $cnt++;
        } else {
            $cnt = 1;
        }
        if ($max < $cnt) {
            $max = $cnt;
        }

    }
    $res[] = $max;
}

foreach ($res as $r) {
    echo $r . "\n";
}

<?php

/**
 * @author Pablo Digiani <p.digiani@gmail.com>
 * @link https://codeforces.com/problemset/problem/1478/A
 * @version 1.0
 *
 * It took me some minutes to understand what was being requested, but then the solution comes instantly.
 * Note that the use of the explode function makes reading "n" unnecessary
 *
 */

$t = readline();
$responses = [];
for($i = 1; $i<= $t; $i++){

    $n = readline();
    $numbers = explode(' ', readline());

    $sequences = [];
    foreach ($numbers as $number){
        $added = false;
        foreach ($sequences as &$sequence){
            if(!in_array($number, $sequence)){
                $sequence[]= $number;
                $added = true;
                break;
            }
        }
        if(!$added) $sequences[] = [$number];
    }
    $responses[]= count($sequences);
}

foreach ($responses as $r) echo $r . PHP_EOL;

<?php

$t = readline();
$responses = [];
for($i = 1; $i<= $t; $i++){
    $n = readline();
    $numbers = explode(' ', readline());

    $sequences = [];
    foreach ($numbers as $number){
        if(empty($sequences)){
            $sequences[] = [$number];
        }else{
            $added = false;
            foreach ($sequences as &$sequence){
                if(!in_array($number, $sequence)){
                    $sequence[]= $number;
                    $added = true;
                    break;
                }
            }
            if(!$added) $sequences[] = [$number];

        }
    }
    $responses[]= count($sequences);
}

foreach ($responses as $r) echo $r . PHP_EOL;

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     $b = trim(fgets(STDIN));
     $c = explode(" ", trim(fgets(STDIN)));
     $d = array();
     for($y = 0; $y < $b; $y++)
     {
          $d[$c[$y]]++;
     }
     print max($d) . "\n";
}
?>

<?php

$t = (int) trim(fgets(STDIN));
for ($i = 0; $i < $t; ++$i) {
    $n[] = (int) trim(fgets(STDIN));
    $a[$i] = array_map('intval', explode(' ', trim(fgets(STDIN))));
}
for ($i = 0; $i < $t; ++$i) {
    echo $cnt = max(array_count_values($a[$i])), PHP_EOL;
}

<?php

$iCount = read();

for($i=0; $i < $iCount; $i++) {
    read();
    $aTest = explode(' ', read());
    $aData = [];
    foreach ($aTest AS $iV) {
        $iV = (int)$iV;
        if(!isset($aData[$iV])) {
            $aData[$iV] = 1;
        } else {
            $aData[$iV]++;
        }
    }

    $aData = array_flip($aData);
    ksort($aData);
    $aData = array_flip($aData);
    $iMax = end($aData);
    write($iMax);
}

function write($a) {
    echo $a . "\n";
}

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

<?php
# ╔══╗─╔═══╗╔╗╔═╗╔════╗╔═══╗╔════╗
# ║╔╗║─║╔══╝║║║╔╝╚══╗═║║╔═╗║║╔╗╔╗║
# ║╚╝╚╗║╚══╗║╚╝╝───╔╝╔╝║║─║║╚╝║║╚╝
# ║╔═╗║║╔══╝║╔╗║──╔╝╔╝─║╚═╝║──║║
# ║╚═╝║║╚══╗║║║╚╗╔╝═╚═╗║╔═╗║──║║
# ╚═══╝╚═══╝╚╝╚═╝╚════╝╚╝─╚╝──╚╝

class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
}

//$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $a = IO::arr();
    $res = [];
    foreach ($a as $v) {
        if(isset($res[$v])) {
            $res[$v] += 1;
        } else {
            $res[$v] = 1;
        }
    }
    IO::line(max($res));
}

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $n; $i++) {
    list($m) = explode(' ', trim(fgets(STDIN)));
    $aList = explode(' ', trim(fgets(STDIN)));
    $aCount = [];
    foreach ($aList as $sK => $sV) {
        if (!isset($aCount[$sV])) {
            $aCount[$sV] = 1;
        } else {
            $aCount[$sV] += 1;
        }
    }
    echo max($aCount). "\n";
}

<?php

$n = readline();

while ($n--) {
    $m = readline();
    $nums = explode(' ', readline());
    $cnt = 1;
    $mid = intdiv(count($nums), 2);
//    echo $del; exit;
    if (count($nums) == 1){
        $res[] = 1; break;
    }

    $max = -1;
    for ($i = 0; $i < count($nums)-1; $i++) {
        if ($nums[$i] == $nums[$i+1]) {
            $cnt++;
        } else {
                $cnt = 1;

        }
        if ($max < $cnt) {
            $max = $cnt;
        }

    }
    $res[] = $max;
}

foreach ($res as $r) {
    echo $r . "\n";
}

<?php

$n = readline();

while ($n--) {
    $m = readline();
    $nums = explode(' ', readline());
    $cnt = 0;
    $del = intdiv(count($nums), 2);
//    echo $del; exit;
    if (count($nums) == 1){
        $res[] = 1; break;
    }

    for ($i = 0; $i < count($nums)-1; $i++) {
        $del--;
        if ($i >= intdiv(count($nums), 2)){
            break;
        }
        if ($del < 0) {
            if ($nums[$i] >= $nums[count($nums) - 1]) {
                $cnt++;
//                continue;
            }
            echo 'aaa';
            break;
        }
        if ($nums[$i] < $nums[count($nums) - $i - 1]) {
            $cnt++;
        } else {
            $cnt+=2;
        }
    }
    $res[] = $cnt;
}

foreach ($res as $r) {
    echo $r . "\n";
}

<?php

$n = readline();

while ($n--) {
    $m = readline();
    $nums = explode(' ', readline());
    $cnt = 0;
    $del = intdiv(count($nums), 2);
//    echo $del; exit;
    if (count($nums) == 1){
        $res[] = 1; break;
    }

    for ($i = 0; $i < count($nums)-1; $i++) {
        $del--;
        if ($del < 0) {
            if ($nums[$i] >= $nums[count($nums) - 1]) {
                $cnt++;
                continue;
            }
            break;
        }
        if ($nums[$i] < $nums[count($nums) - $i - 1]) {
            $cnt++;
        } else {
            $cnt+=2;
        }
    }
    $res[] = $cnt;
}

foreach ($res as $r) {
    echo $r . "\n";
}

<?php

$n = readline();

while ($n--) {
    $m = readline();
    $nums = explode(' ', readline());
    $cnt = 0;
    $del = intdiv(count($nums), 2);
//    echo $del; exit;
    if (count($nums) == 1){
        $res[] = 1; break;
    }

    for ($i = 0; $i < count($nums)-1; $i++) {
        $del--;
        if ($del < 0) {

            break;
        }

        if ($nums[$i] < $nums[count($nums) - $i - 1]) {
            $cnt++;
        } else {
            $cnt+=2;
        }
    }
    $res[] = $cnt;
}

foreach ($res as $r) {
    echo $r . "\n";
}

<?php

/**
 * @author Pablo Digiani <p.digiani@gmail.com>
 * @link https://codeforces.com/problemset/problem/1478/A
 * @version 1.0
 *
 * It took me some minutes to understand what was being requested, but then the solution comes instantly.
 * Note that the use of the explode function makes reading "n" unnecessary
 *
 */

$t = readline();
$responses = [];
for($i = 1; $i<= $t; $i++){

    $n = readline();
    $numbers = explode(' ', readline());

    $sequences = [];
    foreach ($numbers as $number){
        $added = false;
        foreach ($sequences as $sequence){
            if(!in_array($number, $sequence)){
                $sequence[]= $number;
                $added = true;
                break;
            }
        }
        if(!$added) $sequences[] = [$number];
    }
    $responses[]= count($sequences);
}

foreach ($responses as $r) echo $r . PHP_EOL;

<?php
$t = readline();
$responses = [];
for($i = 1; $i<= $t; $i++){
    $n = readline();
    $numbers = explode(' ', readline());

    $sequences = [];
    foreach ($numbers as $number){
        $added = false;
        foreach ($sequences as $sequence){
            if(!in_array($number, $sequence)){
                $sequence[]= $number;
                $added = true;
                break;
            }
        }
        if(!$added) $sequences[] = [$number];
    }
    $responses[]= count($sequences);
}

foreach ($responses as $r) echo $r . PHP_EOL;


<?php
$no = 'NO';
$yes = 'YES';
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647
$alph = 'abcdefghijklmnopqrstuvwxyz';
$inter = "\n";
define("INTMAXVALUE",     2147483646);

 $loop = true;
 $t = $loop ? IO::getInt() : 1;
 while($t--) {
      solve();
 }

 function solve()
 {
     $n = IO::getInt();
     $s = IO::getArray();
     $ans = 0;
     $count= 0;

     $p = [];
    $ok = true;
    $beg = 0;
    while ($beg < $n) {
      $end = $beg;
      while ($end + 1 < $n && $s[$end + 1] == $s[$end]) {
        $end += 1;
      }
      if ($beg == $end) {
        $ok = false;
        break;
      }
      $p[$beg] = $end;
      for ($i = $beg + 1; $i <= $end; $i++) {
        $p[$i] = $i-1;
      }
      $beg = $end + 1;
    }
    if (!$ok) {
      IO::pr('-1');
    } else {
          for ($i = 0; $i < $n; $i++) {
               echo $p[$i] + 1, ' ';
         }
         echo "\n";
    }

 }

 class IO {
      public static function getInt()
      {
          return trim(fgets(STDIN));
      }

     public static function getArray()
     {
         return explode(' ', trim(fgets(STDIN)));
     }
     public static function pr($s)
     {
          echo $s, PHP_EOL;
     }
     public static function prArray($s)
     {
          echo implode( ' ', $s), PHP_EOL;
     }
     public static function getMinValue($x, $y) {
         return $x > $y ? $y : $x;
     }
     public static function getMaxValue($x, $y) {
         return $x > $y ? $x : $y;
     }
 }

 class Algor {
     public static function efclidLcm($a, $b) {
         return ($a  / self::efclidGcd($a, $b)) * $b;
     }
     public static function efclidGcd($a, $b) {
             return $b > 0 ? self::efclidGcd($b, $a % $b) : $a;
     }
    public static function isPrime($n) {
         $d = 2;
         while ($n % $d != 0) {
         $d += 1;
         }

        return $d == $n;
    }

     public static function fabicon($n, $a) {
         if($n <= 1) {
             return $a[$n];
         }
         for($i=2; $i<=$n; $i++) {
             $a[$i] = $a[$i-1] + $a[$i-2];
         }

         return $a[$n];
     }

     function getRotate($a, $s, $e, $ind) {
         $ar = [];
         for ($i= $s; $i<=$e; $i++) {
             $ar[$i] = $a[$i];
             $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;
             // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , "\n";
             $a[$i] = $j < $i ? $ar[$j] : $a[$j];
         }
         return $a;
     }

}

class bigOperation {
     public static function efclidLcm($a, $b) {
         return bcmul(bcdiv($a,  self::efclidGcd($a, $b)), $b);
     }
     public static function efclidGcd($a, $b) {
             return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a;
     }
    public static function  isBigNumber($n)
    {
        return bccomp($n, INTMAXVALUE) == 1;
    }
    // bcadd — Сложить 2 числа произвольной точности
    public static function  bcAdd($x, $y)
    {
        return bcadd($x, $y);
    }
// bccomp — Сравнение двух чисел произвольной точности
//return 1 if x>y, 0= x==y, -1 x < y
    public static function  bcComp($x, $y)
    {
        return bccomp($x, $y);
    }
// bcdiv — Операция деления для чисел произвольной точности
    public static function  bcDiv($x, $y)
    {
        return bcdiv($x, $y);
    }
// bcmod — Получает остаток от деления чисел с произвольной точностью
    public static function  bcMod($x, $y)
    {
        return bcmod($x, $y);
    }
// bcmul — Умножение двух чисел с произвольной точностью
    public static function  bcMul($x, $y)
    {
        return bcmul($x, $y);
    }
// bcpow — Возведение в степень чисел с произвольной точностью
    public static function  bcPow($x, $y)
    {
        return bcpow($x, $y);
    }
// bcpowmod — Возводит одно число в степень другого и возвращает остаток от деления результата на третье число
// bcscale — Задает количество чисел после десятичной точки по умолчанию для всех bc math функций.
// bcsqrt — Извлекает квадратный корень из числа с произвольной точностью
    public static function  bcSqrt($x, $y)
    {
        return bcsqrt($x, $y);
    }
// bcsub — Вычитает одно число с произвольной точностью из другого
    public static function  bcSub($x, $y)
    {
        return bcsub($x, $y);
    }
    public static function getMaxValue($x, $y) {
        return bccomp($x, $y) == 1 ? $x : $y;
    }
    public static function getMinValue($x, $y) {
        return bccomp($x, $y) == 1 ? $y : $x;
    }

    public static function getDareje($n, $k) {
        if($k == 0) {
            return 1;
        }
        return bcmul($n, self::getDareje($n, $k-1));
    }
}

class Sorting
{
    public static function mergeSort($aArray) {
        if(count($aArray) <= 1) {
            return $aArray;
        }
        $aLeft = [];
        $aRight = [];
        $n =floor(count($aArray) / 2);
        for($i = 0; $i <$n; $i++) {
            $aLeft[] = $aArray[$i];
        }
        for($i = $n; $i <count($aArray); $i++) {
            $aRight[] = $aArray[$i];
        }

        return self::merge(self::mergeSort($aLeft), self::mergeSort($aRight));
    }

    public static function merge($aLeft, $aRight) {
        $aResult = [];
        $iL = 0;
        $iR = 0;

        while($iL < count($aLeft) && $iR < count($aRight)) {
            if($aLeft[$iL] <= $aRight[$iR]) {
                $aResult[] = $aLeft[$iL];
                $iL++;
            } else {
                $aResult[] = $aRight[$iR];
                $iR++;
            }
        }

        while($iL < count($aLeft)) {
            $aResult[] = $aLeft[$iL];
            $iL++;
        }
        while($iR < count($aRight)) {
            $aResult[] = $aRight[$iR];
            $iR++;
        }

        return $aResult;

    }
}

class SolveArchive
{

}

<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fgets(STDIN);
    $result = [];
    $arr = [1];
    foreach (fgetcsv(STDIN, 0, ' ') as $key => $value) {
        $key += 1;
        if ($arr[0] == $key) {
            $arr = [$key, $value, false];
        } elseif ($arr[1] != $value) {
            if ($arr[2]) {
                $result[] = $arr[0];
                $arr = [$key, $value, false];
            } else {
                $arr = [2 => false];
                $result = [];
                break;
            }
        } else {
            $result[] = $key;
            $arr[2] = true;
        }
    }
    if (empty($arr[2])) {
        $result = [];
    } else {
        $result[] = $arr[0];
    }
    echo ($result ? implode(' ', $result) : '-1'), "\n";
}

<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fgets(STDIN);
    $result = [];
    $arr = [1];
    foreach (fgetcsv(STDIN, 0, ' ') as $key => $value) {
        $key += 1;
        if ($arr[0] == $key) {
            $arr[1] = $value;
            $arr[2] = false;
        } elseif ($arr[1] != $value) {
            if ($arr[2]) {
                $result[] = $arr[0];
                $arr = [$key, $value, false];
            } else {
                $arr = [2 => false];
                $result = [];
                break;
            }
        } else {
            $result[] = $key;
            $arr[2] = true;
        }
    }
    if ($arr[2]) {
        $result[] = $arr[0];
    }
    echo ($result ? implode(' ', $result) : '-1'), "\n";
}

<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fgets(STDIN);
    $result = [];
    $arr = [1];
    foreach (fgetcsv(STDIN, 0, ' ') as $key => $value) {
        $key += 1;
        if ($arr[0] == $key) {
            $arr[1] = $value;
            $arr[2] = false;
        } elseif ($arr[1] != $value) {
            if ($arr[2]) {
                $result[] = $arr[0];
                $arr = [$key, $value, false];
            } else {
                $arr = [];
                $result = [-1];
                break;
            }
        } else {
            $result[] = $key;
            $arr[2] = true;
        }
    }
    if ($arr) {
        $result[] = $arr[0];
    }
    echo implode(' ', $result), "\n";
}


<?php
/** SECTION 0: NOTES **/
/*
Problem:
Codeforces Contest 192 Div 1 Problem A

Author          : chaotic_iak (http://chaoticiak.comlu.com/)
Language        : PHP 5.4
Released under  : CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
Template version: 20130717 (http://chaoticiak.comlu.com/prog/assorted/templates.phps)
                           (http://ideone.com/AV2T2U)
*/

/** SECTION 1: SET UP INPUT HANDLER **/
// 0: Don't output format at all
// 1: Trim newline characters only
// 2: Assume \x00..\x20 (accaw) as delimiters and output as array

if (isset($inputstream)) {$stdin = $inputstream;} else {$stdin = fopen("php://stdin", "r");}
function g($format = 2) {
    global $stdin;
    $input = fgets($stdin);
    if ($format == 0) {return $input;}
    $input = trim($input, "\n\r");
    if ($format == 1) {return $input;}
    $input = trim($input, "\x00..\x20");
    $input = preg_replace("/[\\x00-\\x20]+/", " ", $input);
    return explode(" ", $input);
}

/** SECTION 2: IMPORTING FUNCTIONS FROM chaotic_iak'S LIBRARY **/
// none

/** SECTION 3: SOLVING THE PROBLEM **/
$n = g(1);
for ($i = 0; $i < $n; $i++) {
	$temp = g(1);
	for ($j = 0; $j < $n; $j++) {
		$cell[$i][$j] = (substr($temp, $j, 1) == ".") ? 1 : 0;
	}
}

//attempt 1
$res = "";
$success = true;
for ($i = 0; $i < $n; $i++) {
	$flag = false;
	for ($j = 0; $j < $n; $j++) {
		if ($cell[$i][$j]) {
			if (!$flag) {$res .= ($i+1) . " " . ($j+1) . "\n";}
			$flag = true;
			break;
		}
	}
	if (!$flag) {$success = false; break;}
}
if ($success) {echo $res;}

//attempt 2
if (!$success) {

$res = "";
$success = true;
for ($i = 0; $i < $n; $i++) {
	$flag = false;
	for ($j = 0; $j < $n; $j++) {
		if ($cell[$j][$i]) {
			if (!$flag) {$res .= ($j+1) . " " . ($i+1) . "\n";}
			$flag = true;
			break;
		}
	}
	if (!$flag) {$success = false; break;}
}
if ($success) {echo $res;}

}

if (!$success) {echo "-1";}

<?php
/** SECTION 0: NOTES **/
/*
Problem:
Codeforces Contest 192 Div 1 Problem A

Author          : chaotic_iak (http://chaoticiak.comlu.com/)
Language        : PHP 5.4
Released under  : CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
Template version: 20130717 (http://chaoticiak.comlu.com/prog/assorted/templates.phps)
                           (http://ideone.com/AV2T2U)
*/

/** SECTION 1: SET UP INPUT HANDLER **/
// 0: Don't output format at all
// 1: Trim newline characters only
// 2: Assume \x00..\x20 (accaw) as delimiters and output as array

if (isset($inputstream)) {$stdin = $inputstream;} else {$stdin = fopen("php://stdin", "r");}
function g($format = 2) {
    global $stdin;
    $input = fgets($stdin);
    if ($format == 0) {return $input;}
    $input = trim($input, "\n\r");
    if ($format == 1) {return $input;}
    $input = trim($input, "\x00..\x20");
    $input = preg_replace("/[\\x00-\\x20]+/", " ", $input);
    return explode(" ", $input);
}

/** SECTION 2: IMPORTING FUNCTIONS FROM chaotic_iak'S LIBRARY **/
// none

/** SECTION 3: SOLVING THE PROBLEM **/
$n = g(1);
for ($i = 0; $i < $n; $i++) {
	$temp = g(1);
	for ($j = 0; $j < $n; $j++) {
		$cell[$i][$j] = (substr($temp, $j, 1) == ".") ? 1 : 0;
	}
}

//attempt 1
$res = "";
$success = true;
for ($i = 0; $i < $n; $i++) {
	$flag = false;
	for ($j = 0; $j < $n; $j++) {
		if ($cell[$i][$j]) {
			if (!$flag) {$res .= $i . " " . $j . "\n";}
			$flag = true;
			break;
		}
	}
	if (!$flag) {$success = false; break;}
}
if ($success) {echo $res;}

//attempt 2
if (!$success) {

$res = "";
$success = true;
for ($i = 0; $i < $n; $i++) {
	$flag = false;
	for ($j = 0; $j < $n; $j++) {
		if ($cell[$j][$i]) {
			if (!$flag) {$res .= $j . " " . $i . "\n";}
			$flag = true;
			break;
		}
	}
	if (!$flag) {$success = false; break;}
}
if ($success) {echo $res;}

}

if (!$success) {echo "-1";}


<?php
# A. Ксюша и массив

$count = trim(fgets(STDIN));
$arr = trim(fgets(STDIN));
$arr = explode(' ', $arr);

$arr = array_unique($arr);
$arr = array_values($arr);
$count = count($arr);
$result = -1;

for ($i = 0; $i < $count; $i++) {
    if ($arr[$i] == 1) {
        $result = 1;
        break;
    } else {
        for ($j = 0; $j < $count; $j++) {
            if ($arr[$j] % $arr[$i] != 0) {
                break;
            }
            if ($j == $count-1) {
                $result = $arr[$i];
                break;
            }
        }
    }
}

echo $result;

<?php
# A. Ксюша и массив

$count = trim(fgets(STDIN));
$arr = trim(fgets(STDIN));
$arr = explode(' ', $arr);

$arr = array_unique($arr);
$count = count($arr);
$result = -1;
for ($i = 0; $i < $count; $i++) {
    if ($arr[$i] == 1) {
        $result = 1;
        break;
    } else {
        for ($j = 0; $j < $count; $j++) {
            if ($arr[$j] % $arr[$i] != 0) {
                break;
            }
            if ($j == $count-1) {
                $result = $arr[$i];
                break;
            }
        }
    }
}

echo $result;

<?php
# A. Ксюша и массив

$count = trim(fgets(STDIN));
$arr = trim(fgets(STDIN));

$arr = explode(' ', $arr);

sort($arr);

$result = -1;

if ($count > 2 && $arr[$count-2] > floor($arr[$count-1]/2) && $arr[$count-2] != $arr[$count-1]) {

} else {
    for ($i = 0; $i < $count; $i++) {
        if ($arr[$i] == 1) {
            $result = 1;
            break;
        } else {
            for ($j = 0; $j < count($arr); $j++) {
                if ($arr[$j] % $arr[$i] != 0) {
                    break;
                }
                if ($j == count($arr)-1) {
                    $result = $arr[$i];
                    break;
                }
            }
        }
    }
}

echo $result;

<?php
# A. Ксюша и массив

$count = trim(fgets(STDIN));
$arr = trim(fgets(STDIN));

$arr = explode(' ', $arr);

$result = -1;
for ($i = 0; $i < count($arr); $i++) {
    if ($arr[$i] == 1) {
        $result = 1;
        break;
    } else {
        for ($j = 0; $j < count($arr); $j++) {
            if ($arr[$i] % $arr[$j] != 0) {
                break;
            }
            if ($j == count($arr)-1) {
                $result = $i;
                break;
            }
        }
    }
}

echo $result;

<?php
# A. Ксюша и массив

#define('STDIN',fopen("php://stdin","r"));

$arr = trim(fgets(STDIN));

/*$arr = array();
for ($i = 0; $i < 5; $i++) {
    array_push($arr, rand(2, 10));
}*/

$arr = explode(' ', $arr);

$result = -1;
for ($i = 0; $i < count($arr); $i++) {
    if ($arr[$i] == 1) {
        $result = 1;
        break;
    } else {
        for ($j = 0; $j < count($arr); $j++) {
            if ($arr[$i] % $arr[$j] != 0) {
                break;
            }
            if ($j == count($arr)) {
                $result = $i;
                break;
            }
        }
    }
}

echo $result;

<?php
# A. Ксюша и массив

$arr = trim(fgets(STDIN));

$arr = explode(' ', $arr);

$result = -1;
for ($i = 0; $i < count($arr); $i++) {
    if ($arr[$i] == 1) {
        $result = 1;
        break;
    } else {
        for ($j = 0; $j < count($arr); $j++) {
            if ($arr[$i] % $arr[$j] != 0) {
                break;
            }
            if ($j == count($arr)-1) {
                $result = $i;
                break;
            }
        }
    }
}

echo $result;

<?php
# A. Ксюша и массив

$count = trim(fgets(STDIN));
$arr = trim(fgets(STDIN));

$arr = explode(' ', $arr);

$result = -1;
for ($i = 0; $i < count($arr); $i++) {
    if ($arr[$i] == 1) {
        $result = 1;
        break;
    } else {
        for ($j = 0; $j < count($arr); $j++) {
            if ($arr[$i] % $arr[$j] != 0) {
                break;
            }
            if ($j == count($arr)-1) {
                $result = $arr[$i];
                break;
            }
        }
    }
}

echo $result;

<?php
# A. Ксюша и массив

$count = trim(fgets(STDIN));
$arr = trim(fgets(STDIN));

$arr = explode(' ', $arr);

$result = -1;
$last = 0;
for ($i = 0; $i < $count; $i++) {
    if ($a[$i] == $last) {
        continue;
    }
    if ($arr[$i] == 1) {
        $result = 1;
        break;
    } else {
        for ($j = 0; $j < $count; $j++) {
            if ($arr[$j] % $arr[$i] != 0) {
                break;
            }
            if ($j == $count-1) {
                $result = $arr[$i];
                break;
            }
        }
    }
}

echo $result;

<?php
# A. Ксюша и массив

$count = trim(fgets(STDIN));
$arr = trim(fgets(STDIN));
$arr = explode(' ', $arr);

$arr = array_unique($arr);
$result = -1;
for ($i = 0; $i < $count; $i++) {
    if ($arr[$i] == 1) {
        $result = 1;
        break;
    } else {
        for ($j = 0; $j < $count; $j++) {
            if ($arr[$j] % $arr[$i] != 0) {
                break;
            }
            if ($j == $count-1) {
                $result = $arr[$i];
                break;
            }
        }
    }
}

echo $result;


<?php
error_reporting("off");
//432B: Football Kit
$n = trim(fgets(STDIN));
$x = array();
$y = array();
for ($i = 0; $i < $n; $i++) {
  list($a, $b) = explode(" ", trim(fgets(STDIN)));
  $x[] = $a;
  $y[] = $b;
}
$xcount = array_count_values($x);
for ($i = 0; $i < $n; $i++) {
  $home = $n - 1;
  $home += $xcount[$y[$i]];
  $away = 2 * ($n - 1) - $home;
  echo $home." ".$away."\n";
}
?>

<?php
error_reporting("off");
//432B: Football Kit
$n = trim(fgets(STDIN));
$x = array();
$y = array();
for ($i = 0; $i < $n; $i++) {
  list($a, $b) = explode(" ", trim(fgets(STDIN)));
  $x[] = $a;
  $y[] = $b;
}
$ycount = array_count_values($y);
for ($i = 0; $i < $n; $i++) {
  $home = $n - 1;
  $home += $ycount[$x[$i]];
  $away = 2 * ($n - 1) - $home;
  echo $home." ".$away."\n";
}
?>


<?php

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

list($n, $m) = array_map('intval', explode(' ', fgets($__fp)));

$martix = [];
$sum = 0;
for ($i = 0; $i < $n; $i++) {
    $martix[$i] = array_map('intval', explode(' ', fgets($__fp)));
    $sum += array_sum($martix[$i]);
}

if ($sum == 0) {
    echo 0;
    exit;
}

$checked = [];

$found = [];

$res = [];

for ($i = 0; $i < $n - 1; $i++) {
    for ($j = 0; $j < $m - 1; $j++) {
        if ($martix[$i][$j] == 1) {

            $r = $martix[$i][$j + 1] + $martix[$i + 1][$j] + $martix[$i + 1][$j + 1];

            $qq = [
                $i . '_' . $j => 1,
                $i . '_' . ($j + 1) => $martix[$i][$j + 1] ,
                ($i + 1) . '_' . $j => $martix[$i + 1][$j],
                ($i + 1) . '_' . ($j + 1) => $martix[$i + 1][$j + 1]
            ];

            $found = array_merge($found, array_filter($qq));
            if ($r == 3) {
                $res[] = ($i + 1) . ' ' . ($j + 1);
                $checked = array_merge($checked, array_filter($qq));
            }
        }
    }
}

if (count($res) == 0 || count($checked) != count($found)) {

    echo -1;
    exit;
}

echo count($res), PHP_EOL, implode(PHP_EOL, $res), PHP_EOL;

<?php

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

list($n, $m) = array_map('intval', explode(' ', fgets($__fp)));

$martix = [];
$sum = 0;
for ($i = 0; $i < $n; $i++) {
    $martix[$i] = array_map('intval', explode(' ', fgets($__fp)));
    $sum += array_sum($martix[$i]);
}

if ($sum == 0) {
    echo 0;
    exit;
}

$res = [];

for ($i = 0; $i < $n - 1; $i++) {
    for ($j = 0; $j < $m - 1; $j++) {
        if ($martix[$i][$j] == 1) {
            if ($martix[$i][$j + 1] && $martix[$i + 1][$j] && $martix[$i + 1][$j + 1]) {
                $res[] = ($i + 1) . ' ' . ($j + 1);
            }
        }
    }
}

if(count($res) == 0)
{
    echo -1;exit;
}

echo count($res), PHP_EOL, implode(PHP_EOL, $res), PHP_EOL;


<?php
# 1141B

$input = fopen('php://stdin', 'rb');
$count = (int)fgets($input);
$line = explode('0', str_repeat(str_replace(' ', '', trim(fgets($input))), 3));
sort($line);
echo strlen(array_pop($line));

<?php
$time = readline();
$hours = readline();
//$time = 7;
//$hours = '1 0 1 1 1 0 1';
$hours = explode (' ',$hours);
$resting = 0;
$max_resting = 0;
foreach ($hours as $v) {
    $hours[] = $v;
}
foreach ($hours as $v) {
    if ($v == 1) {
        $resting += 1;
    } else {
        $resting = 0;
    }
    if ($resting > $max_resting) {
        $max_resting = $resting;
        }
}
echo $max_resting;

<?php

$n = trim(fgets(STDIN));

$day = trim(fgets(STDIN));

$d = explode(' ', $day.' '.$day);

$lgst = 0;
$l = 0;

for($i = 0; $i<2*$n; $i++){
	if($d[$i] == 1){
		$l++;
	}else{
		if($l > $lgst) $lgst = $l;
		$l = 0;
	}
}

fwrite(STDOUT, $lgst);

<?php
// var_dump(3/26);die();

$n = intval(trim(fgets(STDIN)));
$hours = explode(" ",strval(trim(fgets(STDIN))));
$hours = array_merge($hours,$hours);
$continuous_resting_hours_arr = [];
$continuous_resting_hours = 0;
for ($i=0; $i < count($hours); $i++) {

	if($hours[$i]){
		$continuous_resting_hours++;
		// if($i==$n-1){
		// 	if($hours[0]){
		// 		$continuous_resting_hours++;
		// 	}

		// 	$continuous_resting_hours_arr[]=$continuous_resting_hours;
		// }
	}else{
		$continuous_resting_hours_arr[]=$continuous_resting_hours;
		$continuous_resting_hours=0;
		if($i>=$n){
			break;
		}
	}
}
echo max($continuous_resting_hours_arr);

<?php
$n = intval(trim(fgets(STDIN)));
$hours = explode(" ",strval(trim(fgets(STDIN))));

$continuous_resting_hours_arr = [];
$continuous_resting_hours = 0;
for ($i=0; $i < $n; $i++) {

	if($hours[$i]){
		$continuous_resting_hours++;
		if($i==$n-1&&$hours[$i]){
			$continuous_resting_hours++;
			$continuous_resting_hours_arr[]=$continuous_resting_hours;
		}
	}else{
		$continuous_resting_hours_arr[]=$continuous_resting_hours;
		$continuous_resting_hours=0;
	}
}
echo max($continuous_resting_hours_arr);

<?php
// var_dump(3/26);die();

$n = intval(trim(fgets(STDIN)));
$hours = explode(" ",strval(trim(fgets(STDIN))));

$continuous_resting_hours_arr = [];
$continuous_resting_hours = 0;
for ($i=0; $i < $n; $i++) {

	if($hours[$i]){
		$continuous_resting_hours++;
		if($i==$n-1){
			if($hours[0]){
				$continuous_resting_hours++;
			}

			$continuous_resting_hours_arr[]=$continuous_resting_hours;
		}
	}else{
		$continuous_resting_hours_arr[]=$continuous_resting_hours;
		$continuous_resting_hours=0;
	}
}
echo max($continuous_resting_hours_arr);

<?php
// var_dump(3/26);die();

$n = intval(trim(fgets(STDIN)));
$hours = explode(" ",strval(trim(fgets(STDIN))));

$continuous_resting_hours_arr = [];
$continuous_resting_hours = 0;
for ($i=0; $i < $n; $i++) {

	if($hours[$i]){
		$continuous_resting_hours++;
		if($i==$n-1&&$hours[0]){
			$continuous_resting_hours++;
			$continuous_resting_hours_arr[]=$continuous_resting_hours;
		}
	}else{
		$continuous_resting_hours_arr[]=$continuous_resting_hours;
		$continuous_resting_hours=0;
	}
}
echo max($continuous_resting_hours_arr);


<?php

$str = trim(fgets(STDIN));

if (!preg_match("#^(a+)(b+)(c+)$#", $str, $matches)) {
    echo "NO\n";
    die;
}

if (strlen($matches[3]) == strlen($matches[2])
    || strlen($matches[3]) == strlen($matches[1])) {
    echo "YES\n";
    die;
}

echo "NO\n";


<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fgets(STDIN);
    $arr = [];
    $result = 'YES';
    foreach (fgetcsv(STDIN, 0, ' ') as $key => $value) {
     if (($value&1) != ($arr[$key&1] ?? ($arr[$key&1] = $value&1))) {
         $result = 'NO';
         break;
     }
    }
    echo $result, "\n";
}

<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fgets(STDIN);
    $arr = [];
    $result = 'YES';
    foreach (fgetcsv(STDIN, 0, ' ') as $key => $value) {
        if ($value&1 != ($arr[$key&1] ?? ($arr[$key&1] = $value&1))) {
            $result = 'NO';
            break;
        }
    }
    echo $result, "\n";
}


<?php

// თუ თავი შენი შენ გახლავს, ღარიბად არ იხსენები.

// მადლობა გუგას ანდაზისათვის ( : )

$n = fgets(STDIN);

$fib1 =1;
$fib2 =1;

$arr[1]=1;

for($i=1;$i<1001;$i++){
      $fib = $fib2;
      $fib2 = $fib2 + $fib1;
      $fib1 = $fib;
      $arr[$fib]=1;
}

for($i=1;$i<=$n;$i++)
      if(array_key_exists($i,$arr))
            echo 'O';
      else
            echo 'o';

?>


<?php
    define("MAXN", 1024) ;
    define("GAP_VAL", 1e-7) ;

    function gap($n)
    {
        return $n < GAP_VAL ;
    }

//     $t = intval(trim(fgets(STDIN))) ;
//     while($t --)
//     {
//         $n = intval(trim(fgets(STDIN))) ;

//         if($n == 1) echo "-1\n" ;
//         else echo str_repeat("5", $n - 1) . "4\n" ;
//     }
    $n = intval(trim(fgets(STDIN))) ;

    $in_str = explode(" ", trim(fgets(STDIN))) ;

    $b = array() ;

    array_push($b, intval($in_str[0])) ;
    $x = 0 ;
    for($i = 1; $i < $n; $i ++)
    {
        $in_str[$i] = intval($in_str[$i]) ;

        $x = max($x, $b[$i - 1]) ;
        array_push($b, $in_str[$i] + $x) ;
    }

    echo implode(" ", $b) . "\n" ;
?>


<?php

declare(strict_types = 1);

function main() {
	$tests = (int) fgets(STDIN);
	while (($tests--) > 0) {
		[$n, $k] = array_map( 'intval', explode( " ", fgets(STDIN) ) );
		$answer = $n - ($n % $k);
		$answer += min((int)($n % $k), (int)($k / 2));
		echo "$answer\n";
	}
}

main();

<?php

function dd(...$args)
{
    var_dump(...$args);
    die;
}

define('TXTIN', fopen('input.txt', 'r'));
define('TXTOUT', fopen('output.txt', 'w'));

//$input = TXTIN;
$input = STDIN;
//$output = TXTOUT;
$output = STDOUT;

function foo($n, $k)
{
    $od = $n % $k;
    $c = floor($k / 2);

    return $n - $od + min($od, $c);
}

$r = 0;

list($t) = fscanf($input, "%d\n");

for ($i = 0; $i < $t; ++$i) {
    list($n, $k) = fscanf($input, "%d %d\n");

    $r = foo($n, $k);

    fwrite($output, $r . PHP_EOL);
}

<?php
$o = trim(fgets(STDIN));
for($j = 0; $j < $o; $j++){
    $a = explode(" ",trim(fgets(STDIN)));
    $r = array();
    $min = floor($a[0]/$a[1]);
    $b = true;
    $c = false;
    $count = $min * $a[1];
    $count += floor($a[1]/2);
    $count = $count > $a[0] ? $a[0] : $count;
    echo $count."\n";
}

<?php

$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t= trim(fgets($handle));

for($i=0;$i<$t;$i++)
{
    $x=trim(fgets($handle));
    $a=explode(' ',$x);
    $min=(int)($a[0]/$a[1]);
    $hou=$a[0]%$a[1];
    if($hou<=$a[1]/2)
    {
        echo bcadd(bcmul($min,$a[1]),$hou)."\n";
    }else
    {
        echo bcadd(bcmul($min,$a[1]),(int)($a[1]/2))."\n";
    }

}
?>

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

<?php
// $stdin = fopen('input.txt', 'r');

$t = intval(trim(fgets(STDIN)));

for ($i = 0; $i<=$t-1; $i++){

	list($n, $k) = explode(' ', trim(fgets(STDIN)));
	$n = intval($n);
	$k = intval($k);

	$ost = $n % $k;

	echo $n - $ost + min($ost, floor($k/2));

	echo "\n";
}

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

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

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

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

<?php
// $stdin = fopen('input.txt', 'r');

$t = intval(trim(fgets(STDIN)));

for ($i = 0; $i<=$t-1; $i++){

	list($n, $k) = explode(' ', trim(fgets(STDIN)));
	$n = intval($n);
	$k = intval($k);

	$ost = $n % $k;

	echo $n - $ost + min($ost, ceil($k/2));

	echo "\n";
}

<?php
$stdin = fopen('input.txt', 'r');

$t = intval(trim(fgets($stdin)));

for ($i = 0; $i<=$t-1; $i++){

	list($n, $k) = explode(' ', trim(fgets(STDIN)));
	$n = intval($n);
	$k = intval($k);

	$ost = $n % $k;

	echo $n - $ost + min($ost, floor($k/2));

	echo "\n";
}

<?php

declare(strict_types = 1);

function main() {
	$tests = (int) fgets(STDIN);
	while (($tests--) > 0) {
		[$n, $k] = array_map( 'intval', explode( " ", fgets(STDIN) ) );
		$answer = $n - ($n % $k);
		$answer += min((int)($n % $k), (int)($k / 2));
		echo "$answer";
	}
}

main();

<?php

function dd(...$args)
{
    var_dump(...$args);
    die;
}

define('TXTIN', fopen('input.txt', 'r'));
define('TXTOUT', fopen('output.txt', 'w'));

//$input = TXTIN;
$input = STDIN;
//$output = TXTOUT;
$output = STDOUT;

function foo($n, $k)
{
    $a = floor($n / $k);

    $od = $n % $k;

    if ($od === 0 || $od === 1) {
        return $n;
    }

    if (($k > $n) && (($k - $n) > (int)($n / 2))) {
        return 0;
    }

    $c = $a * $k;
    $c += floor($k / 2);

    return $c > $n ? $n : $c;
}

$r = 0;

list($t) = fscanf($input, "%d\n");

for ($i = 0; $i < $t; ++$i) {
    list($n, $k) = fscanf($input, "%d %d\n");

    $r = foo($n, $k);

    fwrite($output, $r . PHP_EOL);
}

<?php

function dd(...$args)
{
    var_dump(...$args);
    die;
}

define('TXTIN', fopen('input.txt', 'r'));
define('TXTOUT', fopen('output.txt', 'w'));

//$input = TXTIN;
$input = STDIN;
//$output = TXTOUT;
$output = STDOUT;

function foo($n, $k)
{
    $a = $n % $k;

    if ($a === 0) {
        return $n;
    }

    if (($k > $n) && (($k - $n) > (int)($n / 2))) {
        return 0;
    }

    $b = (int) ($k / 2);

    $c = $a - $b;

    return $n - $c;
}

$r = 0;

list($t) = fscanf($input, "%d\n");

for ($i = 0; $i < $t; ++$i) {
    list($n, $k) = fscanf($input, "%d %d\n");

    $r = foo($n, $k);

    fwrite($output, $r . PHP_EOL);
}

<?php

function dd(...$args)
{
    var_dump(...$args);
    die;
}

define('TXTIN', fopen('input.txt', 'r'));
define('TXTOUT', fopen('output.txt', 'w'));

//$input = TXTIN;
$input = STDIN;
//$output = TXTOUT;
$output = STDOUT;

function foo($n, $k)
{
    $a = $n % $k;

    if ($a === 0) {
        return $n;
    }

    $b = (int) ($k / 2);
    $c = $a - $b;

    return $n - $c;
}

$r = 0;

list($t) = fscanf($input, "%d\n");

for ($i = 0; $i < $t; ++$i) {
    list($n, $k) = fscanf($input, "%d %d\n");

    $r = foo($n, $k);

    fwrite($output, $r . PHP_EOL);
}


<?php

	$handle = fopen("php://stdin", 'r');
	$readAll = stream_get_contents($handle);
	$contents = explode("\n", $readAll);
	$n = $contents[0];
	$other_contents = explode(' ', $contents[1]);
	$sum = 0;
	$size = sizeof($other_contents);
	for ($i = 0; $i < $size; $i++) {
		$sum += $other_contents[$i];
	}
	echo $sum/$size;

?>

<?php
$stin=fopen("php://stdin", 'r');
$in=stream_get_contents($stin);

$lin = explode("\n",$in);
$n = $lin[0];
$percent = explode(" ",$lin[1]);
$sum =0;
for($i=0;$i<$n;$i+=1){
    $sum += $percent[$i];
}
echo $sum/$n;
?>

<?php
$n = fgets(STDIN);
$d = explode(' ',fgets(STDIN));
$sum = 0;

for( $i=0; $i<$n; $i++ ){
    $sum = $sum + $d[$i];
}

echo $sum/$n;

<?php
$napitki=readline();
$prozenty = readline();

//$napitki = 4;
//$prozenty = '0 25 50 75';
$prozenty = explode(' ', $prozenty);
$sum = 0;
$i=0;
//for ($i = 0; $i < $napitki; $i++) {
foreach ($prozenty as $v) {
    $sum = $sum + $prozenty[$i];
    $i++;
}
    echo $sum / $napitki;

<?php
$stdin = fopen("php://stdin", "r");
$stdout = fopen("php://stdout", "w");
$n = intval(fgets($stdin));
$arr = explode(" ",fgets($stdin));
$sum = 0;
foreach($arr as $data){
$sum += intval($data);
}
fwrite($stdout,$sum * 1.0 / $n);
?>

<?php

fscanf(STDIN , "%f" , $n);
$a = explode(" " , trim(fgets(STDIN)));
$ans = array_sum($a) / $n;
echo $ans;

?>

<?php
fscanf(STDIN, "%d", $n);
$juice = explode(" ", trim(fgets(STDIN)));

echo array_sum($juice) / $n;

?>

<?php

// your code goes here
while($f = fgets(STDIN)){
    $lines[] = $f;
}

function getOrangeProp($lines){
	$drinks = $lines[0];
	$proportions = explode(' ', $lines[1]);
	$totalProp = 0;
	foreach($proportions as $prop){
		$totalProp += $prop;
	}
	$orangeProp = $totalProp/$drinks;
	return $orangeProp;
}

echo getOrangeProp($lines);

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

    foreach($arr as $x)
        $ans += $x;

    echo $ans / sizeof($arr) . PHP_EOL;
?>

<?php
error_reporting("off");
//200B: Drinks
$n = trim(fgets(STDIN)); //$n = 4;
$p = explode(" ", trim(fgets(STDIN))); //$p = explode(" ", "0 25 50 75");
$oj = 0;
$totalml = $n * 100;
foreach ($p as $value) {
    $oj += $value;
}
echo $oj / $totalml * 100;
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
print ($c / ($a * 100)) * 100;
?>

<?php
$i = fgets(STDIN);
if($i==0) die("0");
if($i == 1) die(fgets(STDIN));
$p = explode(" ", fgets(STDIN));
for($t=0; $t<=sizeof($p); $t++)
{
    $pa += $p[$t];
}
echo $pa/$i;
?>

<?php

$data1 = (int) trim(fgets(STDIN));
$data2 = trim(fgets(STDIN));

$main = new MainClass;

echo $main->solution($data1, $data2);

// End of interface

class MainClass {
	//public $problemLink = 'https://codeforces.com/problemset/problem/200/B';
	//public $submissionLink = '';

	public function solution($n, $string)
	{
		$arrayOfStrings = preg_split("/ /", $string);
		$sum = 0;
			for($i = 0; $i < $n; $i++){
				$sum = $sum + (int)$arrayOfStrings[$i];
			}
			return $sum / $n;
	}
}

<?php

$data1 = (int) trim(fgets(STDIN));
$data2 = preg_split("/ /", trim(fgets(STDIN)));

$main = new MainClass;

echo $main->solution($data1, $data2);

// End of interface

class MainClass {
	//public $problemLink = 'https://codeforces.com/problemset/problem/200/B';
	//public $submissionLink = '';

	public function solution($n, $arrayOfStrings)
	{
		$sum = 0;
			foreach ($arrayOfStrings as $value) {
    		$sum += $value;
			}
		return $sum / $n;
	}
}

<?php

$data1 = (int) trim(fgets(STDIN));
$data2 = explode(" ", trim(fgets(STDIN)));

$main = new MainClass;

echo $main->solution($data1, $data2);

// End of interface

class MainClass {
	//public $problemLink = 'https://codeforces.com/problemset/problem/200/B';
	//public $submissionLink = '';

	public function solution($n, $arrayOfStrings)
	{
		$sum = 0;
			foreach ($arrayOfStrings as $value) {
    		$sum += $value;
			}
			return $sum / $n;
	}
}

<?php

error_reporting(0);

solve();

function solve(){

	//$Input = new Input("input.txt");
	$Input = new Input();

	$n = (int)$Input->in();

	$sum = 0;

	for ($i = 0; $i < $n; $i++)
	{
		$sum += (int)$Input->in();
	}

	$p = 100 * $sum / (100 * $n);

	printf("%.12f",$p );
}

class Input{
	private $handle = "";
	private $values = array();
	private $index = 0;

	public function __construct($localfile){

		if (is_file($localfile)) {

			$this->handle = fopen($localfile, "r");
			$contents = stream_get_contents($this->handle);

		} else {

			$contents = stream_get_contents(STDIN);

		}

		$no_newlines = str_replace(array("\r\n", "\r", "\n"), " ", $contents);
		$this->values = explode(" ", $no_newlines);
	}

	public function in(){

		return $this->values[$this->index++];

	}

	public function close(){

		if (is_file($localfile) && feof($this->handle)) fclose($this->handle);

	}
}

?>

<?php

$n = readline();
$ara = explode(' ', readline());
echo array_sum($ara)/$n;

<?php
$n = fgets(STDIN);
print array_sum(explode(' ', fgets(STDIN)))/$n;

<?php
    fscanf(STDIN, "%d", $n);
    $arr = explode(" ", trim(fgets(STDIN)));
    $v = 0;
        for ($i = 0; $i < count($arr); $i++){
           $v = $v + $arr[$i];
        }
        $v = $v / $n ;
        printf("%.12f", $v);

<?php
    $stdin = fopen("php://stdin","r");
    $stdout=fopen("php://stdout","w");
    $cnt=0;$tmp=0;
    fscanf($stdin,"%d\n",&$cnt);
    $sum = 0;
    $st = fgets($stdin);
    /*
    for($i=0;$i<$cnt;$i++){
        fscanf($stdin,"%d ",&$tmp);
        $sum = $sum + $tmp;
    }
    */
    $arr = explode(' ',$st);
    foreach($arr as $v){
        $sum += $v;
    }
    fprintf($stdout,"%.12f\n",($sum/$cnt));
?>

<?php
function input()
{
    while (($line = trim(fgets(STDIN))) != PHP_EOL) {
        yield $line;
    }
}
function intParam($l) {
    return array_map('intval', explode(' ', $l));

}
$COUNT = 0;
foreach (input() as $line) {
    if ($COUNT == 0) {
        $n = intval($line);
        ++$COUNT;
        continue;
    }
    $q = intParam($line);

    $s = 0;
    for($i = 0; $i < $n; ++$i) {
        $s += $q[$i];
    }

    echo $s/$n;

    if (++$COUNT > 1) {
        break;
    }
}

<?php
// Retrieve input and show output
$stream = fopen("php://stdin", "r");
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 126 Division 2 Problem B
function func($in) {
$sum = 0;
for ($x = 1; $x <= $in[0]; $x++) {
	$sum += $in[$x];
}
return ($sum / $in[0]);
}

// End of submission file
// Submission by chaotic_iak
?>

<?php
$stdin = fopen("php://stdin", "r");
$stdout = fopen("php://stdout", "w");
$n = intval(fgets($stdin));
$arr = explode(" ",fgets($stdin));
$sum = 0;
foreach($arr as $data){
$sum += intval($data);
}
fwrite($sum * 1.0 / $n);
?>

<?php
fscanf(STDIN , "%f" , $n);
$ans = 0;
for ($i=0; $i<$n; $i++){
	fscanf(STDIN, "%d", $a);
	$ans+=$a;
}
fprintf(STDOUT, "%f", $ans/$n);


<?php
$line = trim(fgets(STDIN));
$n = intval($line);
$line = trim(fgets(STDIN));
$arr = array_map('intval', explode(' ', $line));

sort($arr);
for($i = 0; $i < $n; $i++) {
	$min = $i == 0 ? $arr[1] - $arr[0] : ($i == $n-1? $arr[$i] - $arr[$i-1]: min($arr[$i] - $arr[$i-1], $arr[$i+1] - $arr[$i]));
	$max = $i == 0 || $i== $n-1 ? $arr[$n-1] - $arr[0] : max($arr[$n-1] - $arr[$i], $arr[$i] - $arr[0]);
	echo $min;
	echo " ";
	echo $max;
	echo "\n";
}

<?php
    $n = trim(fgets(STDIN));
    $arr = explode(" ", trim(fgets(STDIN)));
    sort($arr);
    function max_($index){
        global $arr;
        global $n;
        if($index == 0)
            return $arr[$n-1] -$arr[0];
        else if($index == $n-1){
            return $arr[$n-1] -$arr[0];
        }
        else{
            return $arr[$n-1] -$arr[$index] > $arr[$index] - $arr[0] ? $arr[$n-1] -$arr[$index] : $arr[$index] - $arr[0];
        }
    }
    function min_($index){
        global $arr;
        global $n;
        if($index == 0)
            return $arr[1] -$arr[0];
        else if($index == $n-1){
            return $arr[$n-1] -$arr[$n-2];
        }
        else{
            return $arr[$index] -$arr[$index - 1] > $arr[$index + 1] - $arr[$index] ? $arr[$index + 1] - $arr[$index] : $arr[$index] -$arr[$index - 1];
        }
    }
    for($i = 0;$i<$n; $i++){
        echo min_($i)." ".max_($i)."\n";
    }

<?php

$stdout = fopen(getenv("OUTPUT_PATH"), "w");
$stdin = fopen("php://stdin", "r");

fscanf( $stdin , "%d" , $t ) ;

fscanf( $stdin , "%[^\n]" , $test ) ;

$numbers = array_map( 'intval' , preg_split('/ /' , $test , -1 , PREG_SPLIT_NO_EMPTY ) );

$arr = [] ;

echo ( $numbers[1] - $numbers[0] ) . " " . ( $numbers[$t-1] - $numbers[0] ) . "\n" ;

for( $i=1 ; $i<$t-1 ; $i++)
{
   echo min( $numbers[$i+1] - $numbers[$i] , $numbers[$i] - $numbers[$i-1] ) . " " . max($numbers[$t-1] - $numbers[$i] , $numbers[$i] - $numbers[0] ) . "\n" ;
}

echo ( $numbers[$t-1] - $numbers[$t-2] ) . " " . ( $numbers[$t-1] - $numbers[0] ) . "\n" ;

fwrite($stdout);

fclose($stdin);
fclose($stdout);

?>

<?php

function say($a, $b) {
    echo $a . ' ' . $b . PHP_EOL;
}

$input = fgets(STDIN);
$input = rtrim(fgets(STDIN));
$numbers = explode(' ', rtrim($input));
$countNumbers = count($numbers);

say(
    abs((int)$numbers[1] - (int)$numbers[0]),
    abs((int)$numbers[$countNumbers - 1] - (int)$numbers[0])
);

for ($i = 1; $i < $countNumbers - 1; $i++) {
    say(
        min(
            abs((int)$numbers[$i + 1] - (int)$numbers[$i]),
            abs((int)$numbers[$i] - (int)$numbers[$i - 1])
        ),
        max(
            abs((int)$numbers[$i] - (int)$numbers[0]),
            abs((int)$numbers[$countNumbers - 1] - (int)$numbers[$i])
        )
    );
}

say(
    abs((int)$numbers[$countNumbers - 1] - (int)$numbers[$countNumbers - 2]),
    abs((int)$numbers[$countNumbers - 1] - (int)$numbers[0])
);

<?php
    $n = trim(fgets(STDIN));
    $arr = explode(" ", trim(fgets(STDIN)));
    sort($arr);
    function max_($index){
        global $arr;
        global $n;
        if($index == 0)
            return $arr[$n-1] -$arr[0];
        else if($index == $n-1){
            return $arr[$n-1] -$arr[0];
        }
        else{
            return $arr[$n-1] -$arr[$index] > $arr[0] - $arr[$index] ? $arr[$n-1] -$arr[$index] : $arr[0] - $arr[$index];
        }
    }
    function min_($index){
        global $arr;
        global $n;
        if($index == 0)
            return $arr[1] -$arr[0];
        else if($index == $n-1){
            return $arr[$n-1] -$arr[$n-2];
        }
        else{
            return $arr[$index] -$arr[$index - 1] > $arr[$index + 1] - $arr[$index] ? $arr[$index + 1] - $arr[$index] : $arr[$index] -$arr[$index - 1];
        }
    }
    for($i = 0;$i<$n; $i++){
        echo min_($i)." ".max_($i)."\n";
    }


<?php
// $a = ['a','a'];
// $b = ['b'];
// $c = ['ab','ab'];

$result = [];

function getPointedElements($n, $x)
{
    return 2*$x;
}

$n = explode(" ", trim(fgets(STDIN)));

$nRequestNumber = $n[0];

if( !is_nan($nRequestNumber) )
{
    for($i = 0; $i < $nRequestNumber; $i++)
    {
        $line_data = explode(" ", trim(fgets(STDIN)));
        $n = $line_data[0];
        $x = $line_data[1];

        array_push($result, getPointedElements($n,$x));

    }
}

foreach($result as $value)
{
    echo $value.PHP_EOL;
}

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c) = explode(" ", trim(fgets(STDIN)));
     print $c * 2 . "\n";
}
?>

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
$aArrays = [];
for($i = 0; $i < $c; $i++){
    list($n,$x) = explode(' ', trim(fgets(STDIN)));
    echo $x * 2 . "\n";
}

<?php

$t = trim(fgets(STDIN));

for ($o = 0; $o < $t; $o++)
{
	$data = trim(fgets(STDIN));
	$data = explode(" ", $data);
	$n = $data[0];
	$x = $data[1];
	$ans = 2;
	echo ($ans * $x)."\n";
}

?>


<?php

$t = (int) trim(fgets(STDIN));
for ($i = 0; $i < $t; ++$i) {
    //i[]
    list($ni[], $ki[]) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $si[] = trim(fgets(STDIN));
}
for ($i = 0; $i < $t; ++$i) {
    $n = $ni[$i];
    $k = $ki[$i];
    $s = $si[$i];
    $len = strlen($s);
    echo ($len >= 2 * $k + 1 && substr($s, 0, $k) === strrev(substr($s, -$k, $k)) ? 'YES' : 'NO').PHP_EOL;
}

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  list($n, $k) = explode(" ", trim(fgets($file)));
  $s = trim(fgets($file));

  if ($k == 0 || $n == 1) {
		echo 'YES'.PHP_EOL;
	} else {
		$f = 0;
		if ($n % 2 == 1) {
		  $r = floor($n/2);

			for ($j = 0; $j < $r; $j++) {
				if ($s[$j] == $s[$n - $j - 1]) {
					$f++;
				} else { break; }
			}
			if ($f >= $k) { echo 'YES'.PHP_EOL; }
			else { echo 'NO'.PHP_EOL; }

		} else {
		  $r = floor($n/2) - 1;

			for ($j = 0; $j < $r; $j++) {
				if ($s[$j] == $s[$n - $j - 1]) {
					$f++;
				} else { break; }
			}

			if ($f >= $k) { echo 'YES'.PHP_EOL; }
			else { echo 'NO'.PHP_EOL; }
		}
	}
}

?>

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

	for ($o = 0; $o < $t; $o++) {
		list($n, $k) = explode(" ", trim(fgets(STDIN)));
		$s = trim(fgets(STDIN));
		if ($k == 0) {
			print "YES\n";
			continue;
		} else {
			$c = 0;
			for ($i = 0; $i < floor($n/2); $i++) {
				if ($s[$i] == $s[$n - $i - 1]) {
					$c++;
				}
			}
			if ($n % 2 == 1) {
				if ($k > $c) {
					print "NO\n";
				} else {
					print "YES\n";
				}
			} else {
				if ($k + 1 > $c) {
					print "NO\n";
				} else {
					print "YES\n";
				}
			}
		}
	}
?>

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

	for ($o = 0; $o < $t; $o++) {
		list($n, $k) = explode(" ", trim(fgets(STDIN)));
		$s = trim(fgets(STDIN));
		if ($k == 0) {
			print "YES\n";
			continue;
		} else {
			$c = 0;
			for ($i = 0; $i < $n/2; $i++) {
				if ($s[$i] == $s[$n - $i - 1]) {
					$c++;
				}
			}
			if ($k+1 > $c) {
				print "NO\n";
			} else {
				print "YES\n";
			}
		}
	}
?>

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  list($n, $k) = explode(" ", trim(fgets($file)));
  $s = trim(fgets($file));

  if ($k == 0 || $n == 1) {
		echo 'YES'.PHP_EOL;
	} else {
		$c = 0;
		if ($n % 2 == 1) {
		  $r = floor($n/2);
		  $str = substr($s, 0, $r);
		  $str1 = substr($s, '-'.$r);

			if (strrev($str) == $str1 && strlen($str) >= $k) { echo 'YES'.PHP_EOL; }
			else { echo 'NO'.PHP_EOL; }

		} else {
		  $r = floor($n/2) - 1;
		  $str = substr($s, 0, $r);
		  $str1 = substr($s, '-'.$r);

			if (strrev($str) == $str1 && strlen($str) >= $k) { echo 'YES'.PHP_EOL; }
			else { echo 'NO'.PHP_EOL; }
		}
	}
}

?>


<?php
fscanf(STDIN, "%d\n", $number);
$marks = explode(" ", trim(fgets(STDIN)));
$streak = 0;
$presents = 0;

for ($i=0; $i <= $number-1; $i++) {
  if ($marks[$i] > 3) {
    $streak++;
  } else {
    $streak = 0;
  }

  if ($streak == 3) {
    $presents++;
    $streak = 0;
  }
}

echo $presents;

<?php
fgets(STDIN); // For spend count of numbers
$line = trim(fgets(STDIN));
$line = str_replace(' ', '', $line);
$c = preg_match_all('/(4|5){3}/', $line);
fwrite(STDOUT, $c.PHP_EOL);


<?php
    function is_prime ($n)
    {
        for($x=2; $x * $x <= $n; $x++) {
            if($n % $x == 0) {
                return false;
            }
        }
    return true;
    }

    fscanf(STDIN, "%d", $n);
        for ($i = 4; $i < $n; $i++){
            $a = is_prime($i);
            $b = is_prime($n - $i);
            if (!$a && !$b){
                printf("%d %d", $i, $n - $i);
                // echo ($i . ' ' . $n - $i);
                break;

            }
        }

<?php

$in = fopen("php://stdin", "r");
$number = trim(fgets($in));

$first = $number[0];
$length = strlen($number);
$last = substr($number, -1);
$s = $first * pow(10, $length);
$number = (int) $number;

if ($number[0] > 2) {
  if ($last == 0) {
      $result[] = $number/2;
      $reulst[] = $number/2;
  }

  elseif ($last % 2 == 0) {
   $result[] = $s;
   $result[] = $number - $s;
  }
  else {
     $result[] = $s - 5;
     $result[] = $number - $s - 5;
  }
} else {
  if ($last % 2 == 0) {
    $result[] = $number - 4;
     $result[] = 4;
  }
  else {
    $result[] = $number - 9;
    $result[] = 9;
  }
}

echo implode(" ", $result);

<?
	$n = intval(trim(fgets(STDIN)));
	for ($i=0;$i<=$n;$i++){
		if (isSost($i) && isSost($n-$i)){
			echo $i.' '.($n-$i);
			break;
		}
	}

	function isSost($n){
    	for($i=2;$i<=sqrt($n);$i++)
    	    if(($n % $i) == 0) return true;
    	return false;
	}
?>

<?php
/*
 * A. Уроки дизайна задач: учимся у математики
 */
$n = trim(fgets(STDIN));
($n%2==0) ? printf("%d %d",4,$n-4) : printf("%d %d",9,$n-9);

<?php
$line = fgets(STDIN);
$divider = array(2,3,4,5,6,7,8,9);
$abs = 4;
function isComposite($num)
{
    global $divider;
    $isComposite=0;
    for ($i=0;$i<8;$i++)
    {
        if ($num%$divider[$i]==0)$isComposite++;
    }
    if ($isComposite>=2)return true;
    else return false;
}
while (!(isComposite($line-$abs)&&isComposite($abs)))$abs++;
echo $line-$abs." ".$abs;

<?php
function prime ($x) {
    for($i=2;$i<=sqrt($x);++$i)
        if(!($x%$i))
            return false;
    return true;
}

$stdin = fopen("php://stdin", 'r');
$stdout = fopen("php://stdout", 'w');
fscanf($stdin, "%d", $n);
for($i = 4;$i<$n;++$i) {
    if(!prime($i) && !prime($n-$i)) {
        break;
    }
}
fprintf($stdout, "%d %d", $i , $n - $i);
?>

<?php
    $n = trim(fgets(STDIN));
    function is_prime($n)
    {
        for ($x = 2; $x <= sqrt($n); $x++) {
            if ($n % $x == 0) {
                return false;
            }
        }
        return true;
    }

    for ($i = 1; $i <= 1000000; $i++) {
        if (!is_prime($i)) {
            $s = $n - $i;
            if (!is_prime($s)) {
                echo "{$i} {$s}";
                return;
            }
        }
    }

<?php
// 472A Уроки дизайна задач: учимся у математики

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

$n = fgets($in);
$n = (int) $n;

$prime = array();
//$prime[2] = true;

for ($i=2; $i <= $n; $i++) {
    if (!isset($prime[$i])) {
        for ($j=$i*$i; $j < $n; $j += $i) {
            $prime[$j] = true;
        }
    }
}

for ($i=1; $i <= $n/2 ; $i++) {
    $a = $i;
    $b = $n - $a;
    if (isset($prime[$a]) and isset($prime[$b])) {
        break;
    }
}

echo "$a $b";

?>

<?php

$n = (int)fgets(STDIN);

if ($n % 2 == 0) {
	print implode(' ', array(4, $n - 4));
} else {
	print implode(' ', array(9, $n - 9));
}

<?php

function isPrime($number){
	$sqrt = sqrt($number);
	for ($i = 2; $i <= $sqrt; $i++) {
		if($number%$i == 0){
			return false;
		}
	}
	return true;
}

function solve(){
	$handle = fopen("php://stdin", 'r');
	$number = stream_get_contents($handle);
	$min = 2;
	$max = $number;
	while(true){
		$first_number = rand($min,$max-1);
		$second_number = $number - $first_number;
		if(!isPrime($first_number)&&!isPrime($second_number))
			break;
	}
	fclose($handle);
	if($first_number < $second_number)
		echo $first_number.' '.$second_number;
	else if($first_number > $second_number)
		echo $second_number.' '.$first_number;
	else
		echo $first_number.' '.$second_number;
}

solve();

?>

<?php
/*
 * A. Уроки дизайна задач: учимся у математики
 */

$n = trim(fgets(STDIN));

$random_number = rand(2,$n-2);
$second = $n - $random_number;
echo $random_number.' '.$second;

<?php
$line = trim(fgets(STDIN));
$firstHalf = intval($line/2);
$secondHalf = $line - $firstHalf;
echo $firstHalf." ".$secondHalf;

<?php
// 472A Уроки дизайна задач: учимся у математики

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

$n = fgets($in);
$n = (int) $n;

$a = intval($n / 2);

if (($n % 2) == 0) {
    $b = $a;
} else {
    $b = $a +1;
}
echo "$a $b";

?>

<?php

function solve(){
	$handle = fopen("php://stdin", 'r');
	$number = fread($handle, 1000);
	$min = 2;
	$max = $number;
	$first_number = rand($min,$max-1);
	$second_number = $number - $first_number;
	fclose($handle);
	echo $first_number.' '.$second_number;
}
solve();

?>

<?php

function solve(){
	$handle = fopen("php://stdin", 'r');
	$number = fread($handle, 1);
	$min = 1;
	$max = $number;
	$first_number = rand($min,$max-1);
	$second_number = $number - $first_number;
	fclose($handle);
	echo $first_number.' '.$second_number;
}

solve();

?>


<?php

fscanf(STDIN, '%d', $n);

$e = [];
$v = [];

while ($n--) {
    fscanf(STDIN, '%s', $s);

    for ($i = 0; $i < strlen($s); $i++) {
        $v[$s[$i]] = $s[$i];
        if ($i) {
            $e[$s[$i-1]] = $s[$i];
        }
    }
}

$arr = $v;
foreach ($e as $key => $value) {
    if (isset($arr[$value])) {
        unset($arr[$value]);
    }
}

$results = [];
foreach ($arr as $c) {
    $way = '';
    for ($i = $c; $i; $i = isset($e[$i]) ? $e[$i] : null) {
        $way .= $i;
    }

    $results[$c] = $way;
}

echo implode($results) . PHP_EOL;


<?php
$testsCount = trim( fgets(STDIN) );
for ($i = 1; $i <= $testsCount; $i++) runProgram();

function runProgram()
{
  $presentCount = trim(fgets(STDIN));
  $presentCandies = explode( ' ', trim(fgets(STDIN)) );
  $presentOranges = explode( ' ', trim(fgets(STDIN)) );

  $minCandies = PHP_FLOAT_MAX;
  $minOranges = PHP_FLOAT_MAX;
  for ($i = 0; $i < $presentCount; $i++) {
    if ($presentCandies[$i] < $minCandies) $minCandies = $presentCandies[$i];
    if ($presentOranges[$i] < $minOranges) $minOranges = $presentOranges[$i];
  }

  $actionsCount = 0;
  for ($i = 0; $i < $presentCount;) {
    $candyDiff = $presentCandies[$i] - $minCandies;
    $orangeDiff = $presentOranges[$i] - $minOranges;

    $actions = 0;

    if ($candyDiff > 0 && $orangeDiff > 0) {
      $minDiff = $candyDiff > $orangeDiff ? $orangeDiff : $candyDiff;

      $presentCandies[$i] -= $minDiff;
      $presentOranges[$i] -= $minDiff;

      $actions += $minDiff;
    } else if ($candyDiff > 0) {
      $presentCandies[$i] -= $candyDiff;

      $actions += $candyDiff;
    } else if ($orangeDiff > 0) {
      $presentOranges[$i] -= $orangeDiff;

      $actions += $orangeDiff;
    } else {
      $i++;
      continue;
    }

    $actionsCount += $actions;
  }

  echo $actionsCount, "\n";
}

<?php

$tests = readline();
$answers = [];
for ($t = 1; $t <= $tests; $t++) {

	$gifts = readline();
	$seqA = explode(' ', readline());
	$seqB = explode(' ', readline());

	$minA = min($seqA);
	$minB = min($seqB);

	$moves = 0;
	for($i = 0; $i < $gifts; $i++){
		if($minA < $seqA[$i] && $minB < $seqB[$i]){
			$diffA = $seqA[$i] - $minA;
			$diffB = $seqB[$i] - $minB;
			$max_double_decrements = min([$diffA, $diffB]);
			$moves+= $max_double_decrements;
			if($diffA > $diffB){
				$moves += $diffA - $max_double_decrements;
			}else{
				$moves += $diffB - $max_double_decrements;
			}
		}elseif($minA < $seqA[$i]){
			$moves+= $seqA[$i]- $minA;
		}elseif($minB < $seqB[$i]){
			$moves+= $seqB[$i]- $minB;
		}
	}
	$answers[]= $moves;

}
foreach($answers as $a) echo $a.PHP_EOL;

<?php

$tests = readline();
for ($t = 1; $t <= $tests; $t++) {

	$gifts = readline();
	$seqA = explode(' ', readline());
	$seqB = explode(' ', readline());

	$minA = min($seqA);
	$minB = min($seqB);

	$moves = 0;
	for($i = 0; $i < $gifts; $i++){
		if($minA < $seqA[$i] && $minB < $seqB[$i]){
			$diffA = $seqA[$i] - $minA;
			$diffB = $seqB[$i] - $minB;
			$max_double_decrements = min([$diffA, $diffB]);
			$moves+= $max_double_decrements;
			if($diffA > $diffB){
				$moves += $diffA - $max_double_decrements;
			}else{
				$moves += $diffB - $max_double_decrements;
			}
		}elseif($minA < $seqA[$i]){
			$moves+= $seqA[$i]- $minA;
		}elseif($minB < $seqB[$i]){
			$moves+= $seqB[$i]- $minB;
		}
	}

}
echo $moves;


<?php
$n=trim(fgets(STDIN));
$p=explode(' ',trim(fgets(STDIN)));
$return='YES';
for($i=0;$i<$n;$i++){
	preg_match_all('/(i|e|a|o|u|y)/',trim(fgets(STDIN)),$a);
	if($p[$i]!=count($a[0])) $return='NO';
}
fwrite(STDOUT,$return);

<?php

###### IO ######
error_reporting(E_ALL);
error_reporting(0);

function readString($f) {
	$r = array(
		"\r" => '',
		"\n" => '',
	);
	return strtr(fgets($f), $r);
}

function readNumString($f) {
	return trim(fgets($f));
}

function stringToArray($str) {
	return str_split($str);
}

function readNum($f, $is_int = false) {
	$v = readNumString($f);
	return $is_int ? intval($v) : floatval($v);
}

function readStringExplode($f, $delimiter = ' ') {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = 'trim';
	return array_map($callf, $return);
}

function readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = $is_int ? 'intval' : 'floatval';
	return array_map($callf, $return);
}

###### /IO ######

function getAnswer($is_test = false, $f = false) {
	$stream = STDIN;
	if ($is_test)
		$stream = $f;
	/* begin body */
	$charFind = array('a' => true, 'e' => true, 'i' => true, 'o' => true, 'u' => true, 'y' => true);
	$strCount = readNum($stream, true);
	$rules = readStringExplodeNum($stream, ' ', true);
	$isFail = false;
	for ($i = 0; $i < $strCount; $i++) {
		$str = readString($stream);
		$words = explode(' ', $str);
		$slogCount = 0;
		foreach ($words as $word) {
			$wordLen = strlen($word);
			$wordSlogCount = 0;
			for ($k = 0; $k < $wordLen; $k++) {
				if (!empty($charFind[$word[$k]])) {
					$wordSlogCount++;
				}
			}
			$slogCount+=$wordSlogCount;
		}
		if ($slogCount != $rules[$i]) {
			echo 'NO';
			$isFail = true;
			break;
		}
	}
	if ($isFail === false) {
		echo 'YES';
	}
	/* / end body */
}

if (empty($is_test))
	getAnswer();


<?php
# 1169B
class Pairs {
    /** @var array $x */
    private $x;

    /** @var array $y */
    private $y;

    /** @var boolean */
    private $m;

    /**
     * Pairs constructor.
     * @param array $x
     * @param array $y
     * @param int $m
     */
    public function __construct(array $x, array $y, int $m)
    {
        $this->x = $x;
        $this->y = $y;
        $this->m = $m;
    }

    /**
     * @param int $a
     * @param int $b
     * @return bool
     */
    public function checkPair(int $a, int $b): bool {
        for ($i = 0; $i < $this->m; $i++) {
            if ($this->x[$i] === $a
                || $this->x[$i] === $b
                || $this->y[$i] === $a
                || $this->y[$i] === $b
            ) {
                continue;
            }
            if ($b === 0) {
                return $this->checkPair($a, $this->x[$i]) || $this->checkPair($a, $this->y[$i]);
            }
            return false;
        }
        return true;
    }
}

$stdin = STDIN;
[$n, $m] = fscanf($stdin, '%u %u');

$x = $y = [];
while ([$x_, $y_] = fscanf($stdin, '%u %u')) {
    $x[] = $x_;
    $y[] = $y_;
}
$pairs = new Pairs($x, $y, $m);
echo ($pairs->checkPair($x[0], 0) || $pairs->checkPair($y[0], 0)) ? 'YES' : 'NO';

<?php
# 1169B
$stdin = STDIN;
[$n, $m] = fscanf($stdin, '%u %u');
$unique = $pairs = [];
while ([$x, $y] = fscanf($stdin, '%u %u')) {
    $pairs[] = [min($x, $y), max($x, $y)];
    if (!isset($unique[$x])) {
        $unique[$x] = 0;
    }
    if (!isset($unique[$y])) {
        $unique[$y] = 0;
    }
    $unique[$x]++;
    $unique[$y]++;
}
$keys = [];
if (count($unique) === 2) {
    die ('YES');
}
arsort($unique);
foreach ($unique as $a => $item) {
    break;
}
$result = false;
foreach ($unique as $b => $amount) {
    if ($a === $b) {
        continue;
    }
    $fail = false;
    foreach ($pairs as $pair) {
        [$x, $y] = $pair;
        if ($a !== $x && $a !== $y && $b !== $x && $b !== $y) {
            $fail = true;
            break;
        }
    }
    if (!$fail) {
        $result = true;
        break;
    }
}
echo $result ? 'YES' : 'NO';

<?php
# 1169B
class Pairs {
    /** @var array $x */
    private $x;
    /** @var array $y */
    private $y;
    /** @var boolean */
    private $m;

    /**
     * Pairs constructor.
     * @param array $x
     * @param array $y
     * @param int $m
     */
    public function __construct(array $x, array $y, int $m)
    {
        $this->x = $x;
        $this->y = $y;
    }

    /**
     * @param int $a
     * @param int $b
     * @return bool
     */
    public function checkPair(int $a, int $b): bool {
        for ($i = 0; $i < $this->m; $i++) {
            if ($this->x[$i] === $a
                || $this->x[$i] === $b
                || $this->y[$i] === $a
                || $this->y[$i] === $b
            ) {
                continue;
            }
            if ($b === 0) {
                return $this->checkPair($a, $this->x[$i]) || $this->checkPair($a, $this->y[$i]);
            }
            return false;
        }
        return true;
    }
}

$stdin = STDIN;
[$n, $m] = fscanf($stdin, '%u %u');

$x = $y = [];
while ([$x_, $y_] = fscanf($stdin, '%u %u')) {
    $x[] = $x_;
    $y[] = $y_;
}
$pairs = new Pairs($x, $y, $m);
echo ($pairs->checkPair($x[0], 0) || $pairs->checkPair($y[0], 0)) ? 'YES' : 'NO';