jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
function main(input) {
  const lines = input.trim().split("\n");
  const [N, M] = lines.shift().split(' ').map(Number);
  const h = lines.shift().split(' ').map(Number);

  const isGood = Array(N).fill(true);
  lines.forEach(l => {
    const [a, b] = l.split(' ');
    if (h[a-1] > h[b-1]) {
      isGood[b-1] = false;
    } else if (h[a-1] < h[b-1]) {
      isGood[a-1] = false;
    } else {
      isGood[a-1] = false;
      isGood[b-1] = false;
    }
  });
  const res = isGood.filter(g => g).length;
  
  console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(_input) {
    var lines = _input.split("\n");
    var first = lines.shift().split(' ');
    var dai = first[0] * 1;
    var road = first[1] * 1;
    var heights = lines.shift().split(' ').map((item) => item*1);
    var r = Array(dai).fill(true);

    for (var i = 0; i < road; i++) {
        var s = lines[i].split(' ');
        var f = s[0]*1 - 1;
        var n = s[1]*1 - 1;

        if (heights[f] <= heights[n]) r[f] = false;
        if (heights[n] <= heights[f]) r[n] = false;
    }

    var count = 0;
    for (var i = 0; i < dai; i++) {
        if (r[i]) count++;
    }

    console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const main = (input) => {
  input = input.trim().split('\n')
  const [n,] = input[0].split(' ').map(Number)
  const [, ...arr] = input

  const lighthouse = [0, ...input[1].split(' ').map(BigInt)]
  const ans = [false, ...new Array(n).fill(true)]

  for (let i=0; i<arr.length; i++) {
    const [a, b] = arr[i].split(' ').map(Number)

    if (lighthouse[a] >= lighthouse[b]) ans[b] = false
    if (lighthouse[a] <= lighthouse[b]) ans[a] = false
  }

  let count = 0
  for (let i=1; i<ans.length; i++)
    if (ans[i]) count++

  return console.log(count)
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
const main = (input) => {
  input = input.trim().split('\n')
  const [n, m] = input[0].split(' ').map(Number)
  const [, ...arr] = input

  const lighthouse = [0, ...input[1].split(' ').map(Number)]
  const ans = [false, ...new Array(n).fill(true)]

  for (let i=0; i<arr.length; i++) {
    const [a, b] = arr[i].split(' ').map(Number)

    if (lighthouse[a] >= lighthouse[b]) ans[b] = false
    if (lighthouse[a] <= lighthouse[b]) ans[a] = false
  }

  let count = 0
  for (let i=1; i<ans.length; i++)
    if (ans[i]) count++

  return console.log(count)
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	h := make([]int, n)
	good := make([]bool, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
		good[i] = true
	}
	for i := 0; i < m; i++ {
		ai := nextInt() - 1
		bi := nextInt() - 1
		if h[ai] > h[bi] {
			good[bi] = false
		} else if h[ai] < h[bi] {
			good[ai] = false
		} else {
			good[ai] = false
			good[bi] = false
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		if good[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)
	N := nextInt()
	M := nextInt()
	H := make([]int, N)
	heightPeakEnableds := make([]bool, N)
	for i := 0; i < N; i++ {
		H[i] = nextInt()
		heightPeakEnableds[i] = true
	}

	for i := 0; i < M; i++ {
		a := nextInt()
		b := nextInt()
		if H[a-1] > H[b-1] {
			heightPeakEnableds[b-1] = false
		} else if H[a-1] < H[b-1] {
			heightPeakEnableds[a-1] = false
		} else {
			heightPeakEnableds[b-1] = false
			heightPeakEnableds[a-1] = false
		}
	}

	r := 0
	for _, heightPeakEnabled := range heightPeakEnableds {
		if heightPeakEnabled {
			r++
		}
	}
	fmt.Println(r)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(input())
	m, _ := strconv.Atoi(input())
	h := make([]int, n)
	a := make([]int, m)
	b := make([]int, m)
	for i := 0; i < n; i++ {
		h[i], _ = strconv.Atoi(input())
	}
	for i := 0; i < m; i++ {
		a[i], _ = strconv.Atoi(input())
		b[i], _ = strconv.Atoi(input())
	}

	isHigh := make([]bool, n)
	for i := 0; i < n; i++ {
		isHigh[i] = true
	}
	for i := 0; i < m; i++ {
		ai, bi := a[i], b[i]
		ai--
		bi--
		if h[ai] == h[bi] {
			isHigh[ai] = false
			isHigh[bi] = false
		} else if h[ai] < h[bi] {
			isHigh[ai] = false
		} else {
			isHigh[bi] = false
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		if isHigh[i] {
			ans++
		}
	}
	fmt.Println(ans)
}
//  [ruby]
n, _ = gets.to_s.split.map{|t|t.to_i}
h    = [0] + gets.to_s.split.map{|t|t.to_i}

ans = [1] * (n+1)
ans[0] = 0

$<.each do |line|
  
  a, b = line.to_s.split
  a, b = a.to_i, b.to_i
  
  if h[a] < h[b]
    ans[a] = 0
  elsif h[a] > h[b]
    ans[b] = 0
  else
    ans[a] = ans[b] = 0
  end
end

puts ans.sum
//  [ruby]
n, m = gets.to_s.split.map{|t|t.to_i}
h    = [0] + gets.to_s.split.map{|t|t.to_i}

ans = [1] * (n+1)
ans[0] = 0

m.times do
  
  a, b = gets.to_s.split
  a, b = a.to_i, b.to_i
  
  if h[a] < h[b]
    ans[a] = 0
  elsif h[a] > h[b]
    ans[b] = 0
  else
    ans[a] = ans[b] = 0
  end
end

puts ans.sum
//  [ruby]
n, _ = gets.to_s.split.map{|t|t.to_i}
h    = [0] + gets.to_s.split.map{|t|t.to_i}

ans = [1] * (n+1)
ans[0] = 0

$<.each do |line|
  
  a, b = line.to_s.split
  a, b = a.to_i, b.to_i
  
  ans[a] = 0 if h[a] <= h[b]
  ans[b] = 0 if h[a] >= h[b]
end

puts ans.sum
//  [ruby]
n, m = gets.split.map(&:to_i)
arr = [0] + gets.split.map(&:to_i)

flag = Array.new(n+1, true)
flag[0] = false
m.times do
  a, b = gets.split.map(&:to_i)
  ind = arr[a] < arr[b] ? a : b
  flag[ind] = false
end

puts flag.select{|a| a}.count
//  [ruby]
n, m = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)

arr = Array.new(n+1, true)
arr[0] = false
m.times do
  a, b = gets.split.map(&:to_i)
  arr[[a, b].min] = false
end

puts arr.select{|a| a}.count
//  [ruby]
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i).each.with_index(1).sort
r = m.times.map { gets.split.map(&:to_i).sort }

result = 0
while h.length > 0
  h_i, i = h.shift
  result += 1
  r.map{|a, b| a == i ? b : (b == i ? a : nil)}.compact.each do |j|
    h.delete_if{|_, k| j == k}
  end
end

puts result
//  [rust]
use proconio::input;

fn main() {
    input! {
        n: usize, // 展望台
        m: usize, // 道
        h: [i32; n], // 標高
        ab: [(usize, usize); m],
    }
    let mut res_vec = vec![true; n];

    for (a, b) in ab{
        if h[a - 1] >= h[b - 1] {
            res_vec[b - 1] = false;
        }
        if h[b - 1] >= h[a - 1] {
            res_vec[a - 1] = false;
        }
    }

    println!("{}", res_vec.iter().filter(|x| x == &&true).count());
}
//  [rust]
use proconio::{input, fastout};
use proconio::marker::Usize1;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        hhh: [usize; n],
        ab: [(Usize1, Usize1); m],
    }
    let mut heights = vec![1u64; n];
    for (a, b) in ab {
        if hhh[a] <= hhh[b] { heights[a] = 0; }
        if hhh[a] >= hhh[b] { heights[b] = 0; }
    }
    let ans: u64 = heights.iter().sum();
    println!("{}", ans);
}
//  [rust]
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        n: usize, m: usize,
        h: [usize; n],
        ab: [(usize, usize); m],
    }
    let mut ans = vec![true; n];

    for i in 0..m {
        if h[ab[i].0 - 1] < h[ab[i].1 - 1] {
            ans[ab[i].0 - 1] = false;
        } else {
            ans[ab[i].1 - 1] = false;
        }
    }

    println!("{}", ans.iter().filter(|&&x| x).count());
}
//  [rust]
use text_io::*;
use std::process::exit;

fn main(){
    let mut n:usize = read!();
    let mut k:usize = read!();
    let mut g:Vec<usize> = Vec::new();
    let mut v:Vec<usize> = Vec::new();
    for i in 0..n {
        let c:usize = read!();
        v.push(c);
        g.push(1);
    }
    for i in 0..k {
        let mut x:usize = read!();
        let mut y:usize = read!();
        if v[x-1]<v[y-1] {
            g[x-1] = 0;
        }
        else {
            g[y-1] = 0;
        }
    }
    let mut m:usize = 0;
    for i in 0..n {
        m+=g[i];
    }
    println!("{}",m);
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u64,
        m: u64,
        h: [u64; n],
        ab: [(u64, u64); m],
    }

    let mut ans = 0;
    for i in 0..n {
        for j in 0..ab.len() {
            // println!("{:?}", j);
            if ab[j].0 - 1 == i {
                if h[ab[j].0 as usize - 1] <= h[ab[j].1 as usize - 1] {
                    break;
                }
            } else if ab[j].1 - 1 == i {
                if h[ab[j].1 as usize - 1] <= h[ab[j].0 as usize - 1] {
                    break;
                }
            }

            if j == ab.len() - 1 {
                // println!("{} passed", i);
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}
//  [swift]
func input2() -> (Int, Int) {
    let s = readLine()!.split(separator: " ")
    return (Int(s[0])!, Int(s[1])!)
}

func input_ints() -> [Int] {
    return readLine()!.split(separator: " ").map{e in Int(e)!}
}

let (N, M) = input2()
let H = input_ints()
var ans = Array(repeating: true, count: N)

for _ in 0..<M {
    var (A, B) = input2()
    A -= 1
    B -= 1
    if H[A] <= H[B] {
        ans[A] = false
    }
    if H[B] <= H[A] {
        ans[B] = false
    }
}

let count = ans.filter{ e in e }.count
print(count)
//  [swift]
// Peaks

func main() {
    let nm = readLine()!.split(separator: " ").map{Int($0)!}
    let h = ("0 " + readLine()!).split(separator: " ").map{Int($0)!}
    var flugs: [Bool] = Array(repeating: true, count: nm[0] + 1)
    flugs[0] = false
    print(0)
}

main()
//  [swift]
// Peaks

func main() {
    let nm = readLine()!.split(separator: " ").map{Int($0)!}
    let h = ("0 " + readLine()!).split(separator: " ").map{Int($0)!}
    var flugs: [Bool] = Array(repeating: true, count: nm[0] + 1)
    flugs[0] = false
    print(flugs.filter{$0}.count.description)
}

main()
//  [swift]
let nl = readLine()!.split(separator: " ").map { Int($0)! }
let n = nl[0], m = nl[1]
let hn = readLine()!.split(separator: " ").map { Int($0)! }
var ab = [[Int]](repeating: [Int](), count: n)

for _ in 0..<m {
  let abj = readLine()!.split(separator: " ").map { Int($0)! }
  ab[abj[0] - 1] = ab[abj[0] - 1] + [abj[1]]
  ab[abj[1] - 1] = ab[abj[1] - 1] + [abj[0]]
}
var cn = 0
for i in 0..<n {
  if let max = ab[i].max(by: { hn[$0 - 1] > hn[$1 - 1] }) {
    if hn[max - 1] < hn[i] {
      cn += 1
    }
  } else {
    cn += 1
  }
}
print(cn)
//  [typescript]
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const [n, m] = inputs[0].split(' ').map(Number);
  const highList = inputs[1].split(' ').map(Number);
  let result = new Array(n).fill(true);

  for (let i = 2; i < inputs.length; i++) {
    let [from, to] = inputs[i].split(' ').map((value) => Number(value) - 1);

    if (highList[from] < highList[to]) {
      result[from] = false;
    } else if (highList[from] > highList[to]) {
      result[to] = false;
    } else {
      // 標高が等しい時点で「良い展望台」対象外
      result[from] = false;
      result[to] = false;
    }
  }

  console.log(result.filter((value) => value).length);
}
//  [typescript]
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n')
const output = (x: any) => console.log(x)

const [N, M] = input[0].split(' ').map(n => parseInt(n, 10))
const H = input[1].split(' ').map(n => parseInt(n, 10))
let ans: boolean[] = new Array(N).fill(true)

for (let i = 0; i < M; ++i) {
    const [A, B] = input[2 + i].split(' ').map(n => parseInt(n, 10))
    if (H[A-1] < H[B-1]) {
        ans[A-1] = false
    } else if (H[A-1] > H[B-1]) {
        ans[B-1] = false
    } else if (H[A-1] === H[B-1]) {
        ans[A-1] = false
        ans[B-1] = false
    }
}

let counter = 0
ans.map(a => {
    if(a) ++counter
})
output(counter)
//  [typescript]
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const [n, m] = inputs[0].split(' ').map(Number);
  const highList = inputs[1].split(' ').map(Number);
  const maxList = initMaxList(inputs, highList);
  let count = 0;

  // MAX標高と対象展望台を比較し、等しい展望台が良い展望台
  for (let i = 0; i < n; i++) {
    if (highList[i] === maxList[i]) {
      count++;
    }
  }

  console.log(count);
}

// 対象の展望台(from)と繋がる展望台(to)を比較し、最大の標高を設定する
function initMaxList(inputs: string[], highList: number[]): number[] {
  let maxList = inputs[1].split(' ').map(Number);

  for (let i = 2; i < inputs.length; i++) {
    let [from, to] = inputs[i].split(' ').map((value) => Number(value) - 1);

    if (highList[from] < highList[to]) {
      maxList[from] = highList[to];
    } else if (highList[from] > highList[to]) {
      maxList[to] = highList[from];
    } else {
      // 標高が等しい時点で「良い展望台」対象外
      maxList[to] = 0;
      maxList[from] = 0;
    }
  }

  return maxList;
}
//  [typescript]
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        // 4 3
        // 1 2 3 4
        // 1 3
        // 2 3
        // 2 4
        public main(this: TaskA): void {
            const [n, m]: number[] = this.args[0].map(Number);
            const heights: number[] = this.args[1].map(Number);

            const road: number[][] = [];
            for (let i = 2; i < m + 2; i++) {
                road.push(this.args[i].map(Number));
            }

            let map = new Map();
            for (let i = 1; i < n; i++) {
                map.set(i, true);
            }

            for (let i = 0; i < road.length; i++) {
                const road1: number = road[i][0];
                const road2: number = road[i][1];
                const height1: number = heights[road1 - 1];
                const height2: number = heights[road2 - 1];

                if (height1 === height2) {
                    map.set(road1, false);
                    map.set(road2, false);
                }
                if (height1 <= height2) {
                    map.set(road1, false);
                }
                if (height1 >= height2) {
                    map.set(road2, false);
                }
            }

            let ans: number = 0;
            // console.log(map)
            map.forEach((x, y) => {
                // console.log(`${x} ${y}`)
                if (x) ans++
            });

            // for (let i = 0; i < n; i++) {
            //     const myHeight: number = heights[i];
            //     let good: boolean = true;
            //     for (let j = 0; j < road.length; j++) {
            //         if (!road[j].find(x => x === i)) continue;
            //
            //         const height1: number = heights[road[j][0] - 1];
            //         const height2: number = heights[road[j][1] - 1];
            //         const maxHeight: number = Math.max(height1, height2);
            //
            //
            //         if (myHeight < maxHeight) {
            //             good = false;
            //             continue;
            //         }
            //     }
            //     if (good) ans++;
            // }
            console.log(ans);
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}
//  [typescript]

interface ITenbodai {
  id: number;
  height: number;
  otherPlaceHeight: number[];
}
const mainCalc = (input: string) => {
  const {hList, wayList} = inputParser(input)
  const tenbodaiList = hList.map<ITenbodai>((height, index) => {
    return {
      id: index + 1,
      height,
      otherPlaceHeight: [],
    }
  });
  wayList.forEach(({from, to})=> {
    const fromTenbo = tenbodaiList.find(tenbodai => tenbodai.id === from) as ITenbodai;
    const toTenbo = tenbodaiList.find(tenbodai => tenbodai.id === to) as ITenbodai;
    fromTenbo.otherPlaceHeight.push(toTenbo.height);
    toTenbo.otherPlaceHeight.push(fromTenbo.height);
  });
  let count = 0;
  tenbodaiList.forEach((tenbodai) => {
    const otherHightList = tenbodai.otherPlaceHeight
      .filter(value => {
        if (tenbodai.height <= value) {
          return true;
        }
        return false;
      });
    if (otherHightList.length <= 0) {
      count ++;
    }
  });
  console.log(count);
}


const inputParser = (input: string) => {
  const tmp = input.split('\n');
  const [nStr, mStr] = tmp[0].split(' ')
  tmp.shift();
  const hList = tmp[0].split(' ')
  tmp.shift();
  const wayList = tmp.map(value => {
    const [a, b] = value.split(' ')
    return {
      from: Number(a),
      to: Number(b),
    }
  });

  return {
    n: Number(nStr),
    m: Number(mStr),
    hList: hList.map(h => Number(h)),
    wayList: wayList.filter(({to}) => !Number.isNaN(to)),
  }
}
// test
// const Q1 = `4 3
// 1 2 3 4
// 1 3
// 2 3
// 2 4
// `;
// 
// const Q2 = `6 5
// 8 6 9 1 2 1
// 1 3
// 4 2
// 4 3
// 4 6
// 4 6
// `;
// 
// mainCalc(Q1);
// mainCalc(Q2);
mainCalc(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
inputs.shift();

const heights = inputs.shift().split(' ').map(v => parseInt(v, 10));
const towers = new Array(heights.length).fill().map(_ => {
  return [];
});

inputs.forEach(v => {
  const splited = v.split(' ').map(w => parseInt(w, 10) - 1);

  towers[splited[0]].push(splited[1]);
  towers[splited[1]].push(splited[0]);
});

let result = 0;
towers.forEach((t, i) => {
  let good = true;

  if (t.length) {
    t.forEach(t2 => {
      if (heights[i] <= heights[t2]) {
        good = false;
      }
    });
  }

  if (good) {
    ++result;
  }
});
console.log(result);
//  [python]
import math
from functools import reduce
_=input()
print(reduce(math.gcd,map(int,input().split())))
//  [python]
def main():
    N, *A = map(int, open(0).read().split())
    b = None
    for a in A:
        if b is None:
            b = a
            continue
        while b:
            a, b = b, a % b
        b = a
    print(a)
    return


main()
//  [python]
def main():
    N = int(input())
    A = list(map(int, input().split()))
    b = min(A)
    for a in A:
        while True:
            if a % b == 0:
                break
            tb = b
            b = a % b
            a = tb
    print(b)


main()
//  [python]
n = int(input())
xlist = list(map(int,input().split()))
a = xlist[0]
for i in range(1,n):
  a = fractions.gcd(a,xlist[i])
print(a)
//  [python]
n = int(input())
a = list(map(int,input().split()))
g = 0
k = 0
for i in a:
    if i%2 == 0:
        g = 1
    else:
        k = 1
    if g == 1 and k == 1:
        break
if g == 1:
    if k == 1:
        print(1)
    else:
        if len(set(a)) == 1:
            print(a[0])
        else:
            print(2)
else:
    if len(set(a)) == 1:
        print(a[0])
    else:
        print(2)
//  [python]
def main():
    _ = input()
    A = list(map(int, input().split()))
    min_a = min(A)
    mod = sorted(list(set([a % min_a for a in A])))
    if mod == [0]:
        print(min_a)
        exit()
    elif min_a % 2 == 0 and mod[-1] == min_a // 2:
        print(min_a//2)
        exit()

    for a in A:
        if a % 2 == 1:
            print(1)
            exit()
    print(2)


if __name__ == '__main__':
    main()
//  [java]
import java.util.*;
import java.io.*;

public class Main {
	static int gcd (int a, int b) {
	    return b == 0 ? a : gcd (b, a % b);
	}
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int n = in.readInt(); 
		int ans = 0; 
		for(int i = 0; i<n; i++) {
			int x = in.readInt();
			ans = gcd(x,ans); 
		}
		System.out.println(ans); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}
//  [java]
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		ArrayList<Integer> small = new ArrayList();
		int answer = 1;

		for (int i = 0; i < N; i++) {
			int A = scan.nextInt();
			small.add(A);
		}

		Collections.sort(small);
		int B = small.get(0);
		int S = small.get(1);
		if (B == S) {
			answer = B;
		}

		while(answer > 0 && S != B) {
			answer = Math.abs(S - B);
			S = B;
			B = answer;
		}

		if (answer == small.get(0)) {
			for (int i = 0; i < small.size(); i++) {
				if (small.get(i) % answer != 0) {
					answer = small.get(i) % answer;
				}
			}
		}

		System.out.println(answer);
	}
}
//  [java]
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		ArrayList<Integer> small = new ArrayList();
		int answer = 1;

		for (int i = 0; i < N; i++) {
			int A = scan.nextInt();
			small.add(A);
		}

		Collections.sort(small);
		int B = small.get(0);
		int S = small.get(1);
		if (B == S) {
			answer = B;
		}

		while(answer > 0 && S != B) {
			answer = Math.abs(S - B);
			S = B;
			B = answer;
		}

		if (answer == small.get(0)) {
			for (int i = 0; i < small.size(); i++) {
				if (small.get(i) % answer != 0) {
					answer = 1;
				}
			}
		}

		System.out.println(answer);
	}
}
//  [java]
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		ArrayList<Integer> small = new ArrayList();
		int answer = 1;

		for (int i = 0; i < N; i++) {
			int A = scan.nextInt();
			small.add(A);
		}

		Collections.sort(small);
		int B = small.get(0);
		int S = small.get(1);
		if (B == S) {
			answer = B;
		}

		while(answer > 0 && S != B) {
			answer = Math.abs(S - B);
			S = B;
			B = answer;
		}

		System.out.println(answer);
	}
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	int kotae = getint();
	rep1(i, N - 1) {
		kotae = __gcd(getint(), kotae);
	}
	printf("%d", kotae);

	Would you please return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(false), cin.tie(NULL); }

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
    if (ci - cn == cm) {
        fread_unlocked(cn, 1, cm, stdin);
        ci = cn;
    }
    return *ci++;
}
inline int getint() {
    int A = 0;
    if (ci - cn + 16 > cm)
        while ((ct = getcha()) >= '0')
            A = A * 10 + ct - '0';
    else
        while ((ct = *ci++) >= '0')
            A = A * 10 + ct - '0';
    return A;
}

int main() {
    fastio();

    int N = getint();

    int kotae = getint();
    rep(i, N - 1) { kotae = __gcd(getint(), kotae); }
    co(kotae);
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = a[0];
    for (int i = 1; i < n; i++) {
        if (a[i]%ans) {
            ans = a[i]%ans;
        }
    }
    cout << ans << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = a[0];
    for (int i = 1; i < n; i++) {
        if (a[i]%ans) {
            ans = a[i]%ans;
        }
    }
    cout << ans << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i,n) for (int i = 1; i <= (int)(n); i++)

int main()
{
  int n;
  cin >> n;
  
  ll a[n];
  ll mi = 1e10;
  rep(i,n)
  {
    cin >> a[i];
    mi = min(mi,a[i]);
  }
  
  rep(i,n)
  {
    if(a[i] % (int)mi != 0)
    {
      cout << 1 << endl;
      return 0;
    }
  }
  
  cout << mi << endl;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int max(int a,int b){
    int c;
    if(a>=b) c=a;
    else c=b;
    return c;
}
int min(int a,int b){
    int d;
    if(a>=b) d=b;
    else d=a;
    return d;
}
int gcd(int a,int b){
    int c,d,e;
    c=max(a,b);
    d=min(a,b);
    while(c%d!=0){
        e=c%d;
        c=d;
        d=e;
    }
    return d;
}

signed main(void){

    char str[1100000];
    char *tok;
    int m,n;
    int i1,i2,i3,i4,i44;
    int flag=0;
    int k[100001];
    

    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    n=strtol(tok,NULL,10);
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    k[0]=strtol(tok,NULL,10);
    for(i2=1;i2<n;i2++){
        tok=strtok(NULL," ");
        k[i2]=strtol(tok,NULL,10);
    }
    
    for(i1=1;i1<n;i1++){
        k[i1]=gcd(k[i1-1],k[i1]);
    }
    
    
    printf("%d",k[n-1]);

    
    
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    int N;
    int* monsters;
    char* buffer;
    if (scanf("%d ", &N) != EOF) {
        buffer = malloc(sizeof(char)*N*11+1);
        monsters = malloc(sizeof(int)*N);
        if (fgets(buffer, N*11+1, stdin) != NULL) {
            monsters[0] = atoi(strtok(buffer, " "));
            for (int i = 1; i < N; i++) {
                monsters[i] = atoi(strtok(NULL, " "));
            }
        } else {
            free(buffer);
            free(monsters);
            fprintf(stderr, "[x] fgets() error.\n");
            return 1;
        }
    } else {
        fprintf(stderr, "[x] scanf() error.\n");
        return 1;
    }
    int end;
    int min_index;
    while (1) {
        end = 1;
        for (int i = 0; i < N; i++) {
            if (monsters[i] != 0) {
                min_index = i;
                break;
            }
        }
        for (int i = 0; i < N; i++) {
            if (monsters[i] != 0 && monsters[i] < monsters[min_index]) {
                min_index = i;
            }
        }
        for (int i = 0; i < N; i++) {
            if (i != min_index && monsters[i] != 0) {
                monsters[i] = monsters[i] % monsters[min_index];
                end = 0;
            }
        }
        if (end) break;
    }
    printf("%d", monsters[min_index]);
    free(buffer);
    free(monsters);
    return 0;
}
//  [c]
#include<stdio.h>

int nextInt();

int gcd(int a, int b){
	int t;
	if(a < b){t=a; a=b; b=t;}
	if(b < 1){return -1;}
	if(a%b == 0){return b;}
	return gcd(b, a%b);
}

int gcda(int *a, int length){
	if(length <= 0){return -1;}
	if(length == 1){return *a;}
	return gcd(*a, gcda(a+1, length-1));
}

int N, A[100000], ans, i;

int main(){
	N=nextInt();
	for(i=0; i<N; i++){
		A[i]=nextInt();
	}
	ans = gcda(A, N);
	printf("%d\n", ans);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}
//  [c]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;i++)
    {
        cin>>A[i];
    }
    ll res=A[0];
    for(ll i=0;i<N;i++)
    {
        res=GCD(A[i],res);
    }
    cout<<res; 
    return 0;
}
//  [c]
/*#include<iostream>
#include<cstdio>
#include<algorithm>
*/
#include<bits/stdc++.h>
using namespace std;
#define max 100000

int gcd(int big, int small)
{
    if(big<small)
    {
        swap(big,small);
    }
    if(small==0)
    {
        return big;
    }
    gcd(big%small, small);
}

int main()
{
    int n,arr[max],i;
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%d", &arr[i]);
    }

    sort(arr,arr+n);
    int ans=gcd(arr[0],arr[1]);
    for(i=2; i<n; i++)
    {
        ans=gcd(ans,arr[i]);
    }
    printf("%d\n", ans);
    return 0;
}
//  [c]
#include <bits/stdc++.h>
using namespace std;

int main() {
    size_t N;
    cin >> N;
    vector<int> A(N);
    for (int &Ai : A) cin >> Ai;

    while (true) {
        sort(A.begin(), A.end());
        A.erase(unique(A.begin(), A.end()), A.end());

        if (A.size() == 1uL) {
            cout << A.at(0) << '\n';
            return 0;
        }

        for (size_t i = 1uL; i < A.size(); ++i) {
            A.at(i) %= A.at(0);
            if (A.at(i) == 0) {
                A.erase(A.begin() + i);
                --i;
            }
        }
    }

    return 0;
}
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  //最小のやつが他の敵全員を殴る（他の敵HP = 他の敵HP % 最小HP）
  //上の式の結果が0になったらそいつはどうしようもないのでリストから外す
  //一番最小のやつに交代して他の敵を殴る
  //最小のやつ以外のHPが0になるか、殴り終わった後の敵のHPが1になったら終了
  var output = list[0];
  
    for(var i = 1; i < list.length; i++){
      
      output = gcd(output,list[i]);
    }
    //myout(list);
  
  myout(output);
}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}
Main(myin());
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    const a = nextIntArray()
    function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}
    let ans = a[0]
    for(let i = 1; i<a.length; i++){
        ans = gcd(ans, a[i])
    }
    console.log(ans)
}
Main()
//  [javascript]
"use strict";
    
const getGcd = input => {
  let len, a, b;
  len = input.length;
  a = input[ 0 ];
  
  for (let i = 1; i < len; i++) {
    b = input[ i ];
    a = gcdTwoNumbers( a, b );
  }
  
  return a;
}

const gcdTwoNumbers = (x, y) => {
  x = Math.abs(x);
  y = Math.abs(y);
  while(y) {
    let t = y;
    y = x % y;
    x = t;
  }
  return x;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const monsters = arg[1].split(" ").map(n=>parseInt(n));
    
    console.log(getGcd(monsters));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
function gcd(m, n) {
    if (m < n) [m, n] = [n, m]
    let r
    while (n > 0) {
        r = m % n
        m = n
        n = r
    }
    return m
}
const Main = () => {
    let n = nextInt()
    let a = nextIntArray()
    let ans = gcd(a[0], a[1])
    for(let i = 2; i<a.length; i++){
        ans = Math.max(ans, gcd(ans, a[i]))
    }
    console.log(ans)
}
Main()
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  //最小のやつが他の敵全員を殴る（他の敵HP = 他の敵HP % 最小HP）
  //上の式の結果が0になったらそいつはどうしようもないのでリストから外す
  //一番最小のやつに交代して他の敵を殴る
  //最小のやつ以外のHPが0になるか、殴り終わった後の敵のHPが1になったら終了
  var min = Math.min.apply(null,list);
  var minIndex = list.indexOf(min);
  var nextmin = Math.min.apply(null,list);
  var nextminIndex = list.indexOf(min);
  while(list.length != 1){
     min = nextmin;
    minIndex = nextminIndex;
    for(var i = 0; i < list.length; i++){
      if(i == minIndex){
         continue;
      }
      var nextHp = list[i] % min;
      if(nextHp == 0){
         list.splice(i,1);
         i--;
      }else if(nextHp == 1){
         myout(nextHp);
        return;
      }else{
        if(nextmin > nextHp){
           nextmin = nextHp;
          nextminIndex = i;
        }
        list[i] = nextHp;
      }
    }
    //myout(list);
  }
  myout(list[0]);
}

Main(myin());
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  //最小のやつが他の敵全員を殴る（他の敵HP = 他の敵HP % 最小HP）
  //上の式の結果が0になったらそいつはどうしようもないのでリストから外す
  //一番最小のやつに交代して他の敵を殴る
  //最小のやつ以外のHPが0になるか、殴り終わった後の敵のHPが1になったら終了
  while(list.length != 1){
     var min = Math.min.apply(null,list);
    var minIndex = list.indexOf(min);
    for(var i = 0; i < list.length; i++){
      if(i == minIndex){
         continue;
      }
      var nextHp = list[i] % min;
      if(nextHp == 0){
         list.splice(i,1);
         i--;
      }else if(nextHp == 1){
         myout(nextHp);
        return;
      }else{
        list[i] = nextHp;
      }
    }
    //myout(list);
  }
  myout(list[0]);
}

Main(myin());
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func gcd(a, b int) int {
	for b != 0 {
		c := a % b
		a, b = b, c
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := r()

	var x int
	y := r()
	for i := 1; i < n; i++ {
		x = r()
		y = gcd(x, y)
	}

	fmt.Println(y)
}
//  [go]
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
        "strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func gcd(a, b int) int {
        for {
                if b == 0 {
                        return a
                } else {
                        a, b = b, a%b
                }
        }
}

func main() {
        line := readBigLine()
        N := parseInt(line)

        l := readBigLine()
        a := intSprit(l)

        n := gcd(a[0], a[1])
        for i := 2; i < N; i++ {
                n = gcd(n, a[i])
        }
        fmt.Println(n)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

// gcd ...
func gcd(a, b int) int {
	if b > a {
		a, b = b, a
	}
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

// lcm ...
func lcm(a, b int) int {
	g := gcd(a, b)
	return (a / g) * b
}

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	tmp := sc.NextInt()
	for i := 1; i < n; i++ {
		tmp = gcd(tmp, sc.NextInt())
	}
	fmt.Printf("%v\n", tmp)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanInts(n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = nextInt()
	}
	return is
}

func main() {
	N := nextInt()
	IS := scanInts(N)
	sort.Sort(sort.IntSlice(IS))
	for {
		if len(IS) == 1 {
			fmt.Println(IS[0])
			return
		}
		if IS[0] == IS[1] {
			IS = IS[1:]
			continue
		} else if IS[0] == 1 {
			fmt.Println(1)
			return
		}
		a := IS[1] - IS[0]
		b := IS[0]
		IS[1] = max(a, b)
		IS[0] = min(a, b)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanInts(n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = nextInt()
	}
	return is
}

func main() {
	N := nextInt()
	IS := scanInts(N)
	sort.Sort(sort.IntSlice(IS))
	for {
		if IS[0] == IS[1] {
			IS = IS[1:]
			continue
		} else if IS[0] == 1 {
			fmt.Println(1)
			return
		}
		a := IS[1] - IS[0]
		b := IS[0]
		IS[1] = max(a, b)
		IS[0] = min(a, b)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanInts(n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = nextInt()
	}
	return is
}

func main() {
	N := nextInt()
	IS := scanInts(N)
	sort.Sort(sort.IntSlice(IS))
	for {
		if IS[0] == IS[1] {
			fmt.Println(IS[0])
			return
		} else if IS[0] == 1 {
			fmt.Println(1)
			return
		}
		a := IS[1] - IS[0]
		b := IS[0]
		IS[1] = max(a, b)
		IS[0] = min(a, b)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}
//  [ruby]
gets;p gets.split.map(&:to_i).inject(:gcd)
//  [ruby]
n = gets.to_i
a = gets.split.map(&:to_i)

puts a.inject(:gcd)
//  [ruby]
n = gets.to_i
a = gets.split.map(&:to_i)

p a.inject(:gcd)
//  [ruby]

def GCD(m, n)
	return 0 if m == 0 || n == 0
	while m != 0 && n != 0
		if m > n then
			m %= n
		else
			n %= m
		end
	end
	return [m, n].max
end

def LCM(m, n)
	return 0 if m == 0 || n == 0
	return m * n / GCD(m, n)
end



n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i).sort
mod = arr[0]
1.upto(n-1) do |i|
	ngo = arr[i] % mod
	mod = ngo if ngo < mod && ngo > 0
end

puts mod
//  [ruby]
n=gets.to_i
a=gets.split.map(&:to_i)
v=a.uniq!
if v.length==1
    p a[0]
    exit
end

odd=0
even=0

for i in 0..a.length-1
    if odd==1 && even==1
        p 1
        exit
    end
    
    if a[i]%2==1
        odd=1
    else
    even=1
    end
end

p 2
//  [ruby]
n=gets.to_i
a=gets.split.map(&:to_i)
v=a.uniq
if v.length==1
p a[0]
exit
end
a.sort!
while true
    first=a[0]
    second=a[1]
    v=(first-second).abs
    if a.count(v)==0
        a.push(v)
        a.sort!
    else
    break
    end
end
p a[0]