package main

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

func main() {
	n := readi()
	m := readi()
	h := make(map[int]int, n)
	for i := 0; i < n; i++ {
		h[i+1] = readi()
	}
	agg := make(map[int][]int)
	for i := 0; i < m; i++ {
		a := readi()
		b := readi()
		agg[a] = append(agg[a], b)
		agg[b] = append(agg[b], a)
	}

	ans := 0
	for i := 1; i <= n; i++ {
		dists, ok := agg[i]
		if !ok {
			ans++
			break
		}
		for _, dist := range dists {
			if h[i] < h[dist] {
				ok = false
			}
		}
		if ok {
			ans++
		}
	}

	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

// func chmin(x *int, y int) bool {
// 	if *x > y {
// 		*x = y
// 		return true
// 	}
// 	return false
// }

// func chmax(x *int, y int) bool {
// 	if *x < y {
// 		*x = y
// 		return true
// 	}
// 	return false
// }

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

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func nextPermutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func primeFactors(n int) []int {
	factors := make([]int, 0)
	i := 2
	for i*i <= n {
		r := n % i
		if r != 0 {
			i++
		} else if r == 0 {
			n /= i
			factors = append(factors, i)
		}
	}
	if n > 1 {
		factors = append(factors, n)
	}
	return factors
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

func searchInts(a []int, k int) int {
	return binarySearch(len(a), func(i int) bool {
		return a[i] >= k
	})
}

func binarySearch(n int, f func(int) bool) int {
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if !f(h) {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}

func reverseStr(s string) string {
	var b strings.Builder
	b.Grow(len(s))
	for i := len(s) - 1; i >= 0; i-- {
		b.WriteByte(s[i])
	}
	return b.String()
}

type Queue struct {
	items []int
}

func (q *Queue) push(item int) {
	q.items = append(q.items, item)
}

func (q *Queue) pop() {
	q.items = q.items[1:]
}

func (q *Queue) front() int {
	return q.items[0]
}

func (q *Queue) size() int {
	return len(q.items)
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


package main

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

func main() {
	n := readi()
	m := readi()
	h := make(map[int]int, n)
	for i := 0; i < n; i++ {
		h[i+1] = readi()
	}
	agg := make(map[int][]int)
	for i := 0; i < m; i++ {
		a := readi()
		b := readi()
		agg[a] = append(agg[a], b)
		agg[b] = append(agg[b], a)
	}

	ans := 0
	for i := 0; i < n; i++ {
		ok := true
		src := i + 1
		dists, ok := agg[src]
		if !ok {
			ans++
			break
		}
		for _, dist := range dists {
			if h[src] <= h[dist] {
				ok = false
			}
		}
		if ok {
			ans++
		}
	}

	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

// func chmin(x *int, y int) bool {
// 	if *x > y {
// 		*x = y
// 		return true
// 	}
// 	return false
// }

// func chmax(x *int, y int) bool {
// 	if *x < y {
// 		*x = y
// 		return true
// 	}
// 	return false
// }

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

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func nextPermutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func primeFactors(n int) []int {
	factors := make([]int, 0)
	i := 2
	for i*i <= n {
		r := n % i
		if r != 0 {
			i++
		} else if r == 0 {
			n /= i
			factors = append(factors, i)
		}
	}
	if n > 1 {
		factors = append(factors, n)
	}
	return factors
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

func searchInts(a []int, k int) int {
	return binarySearch(len(a), func(i int) bool {
		return a[i] >= k
	})
}

func binarySearch(n int, f func(int) bool) int {
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if !f(h) {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}

func reverseStr(s string) string {
	var b strings.Builder
	b.Grow(len(s))
	for i := len(s) - 1; i >= 0; i-- {
		b.WriteByte(s[i])
	}
	return b.String()
}

type Queue struct {
	items []int
}

func (q *Queue) push(item int) {
	q.items = append(q.items, item)
}

func (q *Queue) pop() {
	q.items = q.items[1:]
}

func (q *Queue) front() int {
	return q.items[0]
}

func (q *Queue) size() int {
	return len(q.items)
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


package main

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

func main() {
	n := readi()
	m := readi()
	h := make(map[int]int, n)
	for i := 0; i < n; i++ {
		h[i+1] = readi()
	}
	agg := make(map[int][]int)
	for i := 0; i < m; i++ {
		a := readi()
		b := readi()
		agg[a] = append(agg[a], b)
		agg[b] = append(agg[b], a)
	}

	ans := 0
	for src, dists := range agg {
		ok := true
		for _, dist := range dists {
			if h[src] < h[dist] {
				ok = false
			}
		}
		if ok {
			ans++
		}
	}

	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

// func chmin(x *int, y int) bool {
// 	if *x > y {
// 		*x = y
// 		return true
// 	}
// 	return false
// }

// func chmax(x *int, y int) bool {
// 	if *x < y {
// 		*x = y
// 		return true
// 	}
// 	return false
// }

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

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func nextPermutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func primeFactors(n int) []int {
	factors := make([]int, 0)
	i := 2
	for i*i <= n {
		r := n % i
		if r != 0 {
			i++
		} else if r == 0 {
			n /= i
			factors = append(factors, i)
		}
	}
	if n > 1 {
		factors = append(factors, n)
	}
	return factors
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

func searchInts(a []int, k int) int {
	return binarySearch(len(a), func(i int) bool {
		return a[i] >= k
	})
}

func binarySearch(n int, f func(int) bool) int {
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if !f(h) {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}

func reverseStr(s string) string {
	var b strings.Builder
	b.Grow(len(s))
	for i := len(s) - 1; i >= 0; i-- {
		b.WriteByte(s[i])
	}
	return b.String()
}

type Queue struct {
	items []int
}

func (q *Queue) push(item int) {
	q.items = append(q.items, item)
}

func (q *Queue) pop() {
	q.items = q.items[1:]
}

func (q *Queue) front() int {
	return q.items[0]
}

func (q *Queue) size() int {
	return len(q.items)
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


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


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


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


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


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


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


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());
}


#[macro_use]
mod input_mcr {
    // ref: tanakh <https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8>
    // diff: using Parser
    #[macro_export(local_inner_macros)]
    macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut parser = Parser::from_str($s);
        input_inner!{parser, $($r)*}
    };
    (parser = $parser:ident, $($r:tt)*) => {
        input_inner!{$parser, $($r)*}
    };
    (new_stdin_parser = $parser:ident, $($r:tt)*) => {
        let stdin = std::io::stdin();
        let reader = std::io::BufReader::new(stdin.lock());
        let mut $parser = Parser::new(reader);
        input_inner!{$parser, $($r)*}
    };
    ($($r:tt)*) => {
        input!{new_stdin_parser = parser, $($r)*}
    };
}

    #[macro_export(local_inner_macros)]
    macro_rules! input_inner {
    ($parser:ident) => {};
    ($parser:ident, ) => {};
    ($parser:ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($parser, $t);
        input_inner!{$parser $($r)*}
    };
}

    #[macro_export(local_inner_macros)]
    macro_rules! read_value {
    ($parser:ident, ( $($t:tt),* )) => {
        ( $(read_value!($parser, $t)),* )
    };
    ($parser:ident, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($parser, $t)).collect::<Vec<_>>()
    };
    ($parser:ident, chars) => {
        read_value!($parser, String).chars().collect::<Vec<char>>()
    };
    ($parser:ident, char_) => {
        read_value!($parser, String).chars().collect::<Vec<char>>()[0]
    };
    ($parser:ident, usize1) => {
        read_value!($parser, usize) - 1
    };
    ($parser:ident, line) => {
        $parser.next_line()
    };
    ($parser:ident, line_) => {
        $parser.next_line().chars().collect::<Vec<char>>()
    };
    ($parser:ident, i64_) => {
        $parser.fast_i64()
    };
    ($parser:ident, usize_) => {
        $parser.fast_i64() as usize
    };
    ($parser:ident, usize1_) => {
        ($parser.fast_i64() - 1) as usize
    };
    ($parser:ident, $t:ty) => {
        $parser.next::<$t>().expect("Parse error")
    };
}

    use std::io;
    use std::io::BufRead;
    use std::str;

    // ref: tatsuya6502 <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e>
    // ref: wariuni <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e#comment-7040a5ae96305e884eb9>
    // diff: using std::io::BufRead::fill_buf()
    pub struct Parser<R> {
        pub reader: R,
        buf: Vec<u8>,
        pos: usize,
    }

    impl Parser<io::Empty> {
        pub fn from_str(s: &str) -> Parser<io::Empty> {
            Parser {
                reader: io::empty(),
                buf: s.as_bytes().to_vec(),
                pos: 0,
            }
        }
    }

    impl<R: BufRead> Parser<R> {
        pub fn new(reader: R) -> Parser<R> {
            Parser {
                reader: reader,
                buf: vec![],
                pos: 0,
            }
        }
        pub fn update_buf(&mut self) {
            self.buf.clear();
            self.pos = 0;
            loop {
                let (len, complete) = {
                    let buf2 = self.reader.fill_buf().unwrap();
                    self.buf.extend_from_slice(buf2);
                    let len = buf2.len();
                    (len, buf2[len - 1] <= 0x20)
                };
                self.reader.consume(len);
                if complete {
                    break;
                }
            }
        }
        pub fn next<T: str::FromStr>(&mut self) -> Result<T, T::Err> {
            loop {
                let mut begin = self.pos;
                while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                    begin += 1;
                }
                let mut end = begin;
                while end < self.buf.len() && (self.buf[end] > 0x20) {
                    end += 1;
                }
                if begin != self.buf.len() {
                    self.pos = end;
                    return unsafe { str::from_utf8_unchecked(&self.buf[begin..end]) }.parse::<T>();
                } else {
                    self.update_buf();
                }
            }
        }
        pub fn next_line(&mut self) -> String {
            loop {
                let mut begin = self.pos;
                if begin < self.buf.len() && (self.buf[begin] < 0x20) {
                    begin += 1;
                }
                let mut end = begin;
                while end < self.buf.len() && (self.buf[end] >= 0x20) {
                    end += 1;
                }
                if begin != self.buf.len() {
                    self.pos = end;
                    return unsafe { str::from_utf8_unchecked(&self.buf[begin..end]) }.to_string();
                } else {
                    self.update_buf();
                }
            }
        }
        pub fn fast_i64(&mut self) -> i64 {
            loop {
                let mut begin = self.pos;
                while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                    begin += 1;
                }
                if begin == self.buf.len() {
                    self.update_buf();
                    continue;
                }
                let mut res = 0;
                let (is_positive, mut end) = match self.buf[begin] {
                    b'+' => (true, begin + 1),
                    b'-' => (false, begin + 1),
                    _ => (true, begin),
                };
                while end < self.buf.len() && (self.buf[end] > 0x20) {
                    res = res * 10 + (self.buf[end] as i64 - '0' as i64);
                    end += 1;
                }
                if begin != self.buf.len() {
                    self.pos = end;
                    return if is_positive { res } else { -res };
                } else {
                    self.update_buf();
                }
            }
        }
    }
}

use input_mcr::*;
use std::cmp::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        hs: [i64; n],
        es: [(usize1,usize1); m],
    }
    let mut ok = vec![true; n];
    for &(s, t) in &es {
        if hs[s] <= hs[t] {
            ok[s] = false;
        }
        if hs[s] >= hs[t] {
            ok[t] = false;
        }
    }
    let res = ok.iter().filter(|&&x| x).count();
    println!("{}", res);
}


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);
}


#[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());
}


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);
}


// -*- 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);
}


import Foundation
let main: () = {
    let (N, M) = *listOfInt()
    let H = listOfInt()
    var G = [[Int]](repeating: [Int](), count: N)
    repeate(M) { m in
        let (A, B) = *listOfInt(-1, -1)
        G[A].append(B)
        G[B].append(A)
    }
    var ans = 0
    G.enumerated().forEach { g in
        let h = H[g.offset]
        if g.element.count == 0 { ans += 1 }
        else {
            var hier = 0
            g.element.forEach {
                if hier < H[$0] { hier = H[$0] }
            }
            if h > hier  { ans += 1 }
        }
    }
    print(ans)
}()

//----------------------------------

let dx = [1, 0, -1, 0] //[1, 0, -1, 0, -1,  1, -1, 1]
let dy = [0, 1, 0, -1] //[0, 1, 0, -1, -1, -1,  1, 1]

@inlinable func gcd(_ a: Int, _ b: Int) -> Int { (b > 0) ? gcd(b, a % b) : a }
@inlinable func lcm(_ a: Int, _ b: Int) -> Int { a / gcd(a, b) * b }

//----------------------------------

infix operator  =~ : ComparisonPrecedence
infix operator !=~ : ComparisonPrecedence
func =~ <T: FixedWidthInteger>(left: T, right: Range<T>) -> Bool { right ~= left }
func !=~ <T: FixedWidthInteger>(left: T, right: Range<T>) -> Bool { !(right ~= left) }
func =~ <T: FixedWidthInteger>(left: T, right: ClosedRange<T>) -> Bool { right ~= left }
func !=~ <T: FixedWidthInteger>(left: T, right: ClosedRange<T>) -> Bool { !(right ~= left) }

func =~ <T: Collection > (left: T.Element, right: T) -> Bool where T.Element : Equatable { right.contains(left) }
func !=~ <T: Collection > (left: T.Element, right: T) -> Bool where T.Element : Equatable { !right.contains(left) }

infix operator /^ : MultiplicationPrecedence
infix operator /^= : AssignmentPrecedence
func /^ <T: FixedWidthInteger>(left: T, right: T) -> T { (left + (right - 1)) / right }
func /^= <T: FixedWidthInteger>(left: inout T, right: T) { left = (left + (right - 1)) / right }

@inlinable func chmax<T: Comparable>(_ m: inout T, _ q: T) { if (m < q) { m = q } }
@inlinable func chmin<T: Comparable>(_ m: inout T, _ q: T) { if (m > q) { m = q } }
@inlinable func chRmax<T: Comparable>(_ m: inout T, _ q: T) -> Bool { if (m < q) { m = q; return true } else { return false } }
@inlinable func chRmin<T: Comparable>(_ m: inout T, _ q: T) -> Bool { if (m > q) { m = q; return true } else { return false } }

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) { (a[0], a[1]) }
prefix func * <T> (a: [T]) -> (T, T, T) { (a[0], a[1], a[2]) }
prefix func * <T> (a: [T]) -> (T, T, T, T) { (a[0], a[1], a[2], a[3]) }
prefix func * <T> (a: [T]) -> (T, T, T, T, T) { (a[0], a[1], a[2], a[3], a[4]) }
prefix func * <T> (a: [T]) -> (T, T, T, T, T, T) { (a[0], a[1], a[2], a[3], a[4], a[5]) }

func printErr(_ str: String, terminator: String = "\n") {
    let s = str + terminator
    FileHandle.standardError.write(s.data(using: .utf8)!)
    FileHandle.standardError.synchronizeFile()
}

@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func nextDouble() -> Double { Double(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt() -> [Int] { listOfString().map { Int($0)! } }
@inlinable func listOfInt(_ offset: Int = 0) -> [Int] { listOfString().map { Int($0)! + offset } }
@inlinable func listOfInt(_ offsets: Int ...) -> [Int] { listOfString().enumerated().map { Int($0.element)! + offsets[$0.offset % offsets.count] } }
@inlinable func listOfDouble(_ offset: Double = 0.0) -> [Double] { listOfString().map { Double($0)! + offset } }
@inlinable func listOfDouble(_ offsets: Double ...) -> [Double] { listOfString().enumerated().map { Double($0.element)! + offsets[$0.offset % offsets.count] } }

extension Int {
    init(s: String) { self.init(s)! }
    var isEven: Bool { self.isMultiple(of: 2) }
    var isOdd: Bool { !self.isEven }
    var isTrue: Bool { self != 0 }
    var isFalse: Bool { !self.isTrue }
    var toString: String { String(self) }
    var toChar: Character { Character(UnicodeScalar(UInt8(self))) }
}
func + (left: Int, right: Bool) -> Int { left + (right ? 1 : 0) }
extension Character {
    var asciiCode: Int { Int(self.asciiValue!) }
    var string: String { String(self) }
}
extension String {
    @inlinable subscript (position: Int) -> Character { self[self.index(self.startIndex, offsetBy: position)] }
    @inlinable func repeate(_ times: Int) -> String { String(repeating: self, count: times) }
    //  @inlinable subscript (n: Int) -> String { String(self[self.index(self.startIndex, offsetBy: n)]) }
    //  @inlinable subscript (n: Int) -> Int { Int(self[self.index(self.startIndex, offsetBy: n)].asciiValue!) }
    var toInt: Int { Int(self)! }
}
extension String { // VB like
    @inlinable func _index(_ position: Int) -> String.Index! {
        if !(0 ..< self.count ~= position) { return nil }
        return self.index(self.startIndex, offsetBy: position)
    }
    @inlinable func mid(from index: Int, length: Int) -> String! {
        if let startPosition = self._index(index) {
            if let endPosition = self._index(index + length - 1) {
                return String(self[startPosition...endPosition])
            } else {
                let endPosition = self.index(before: self.endIndex)
                return String(self[startPosition...endPosition])
            }
        }
        return ""
    }
    @inlinable func left(_ length: Int) -> String { String(self.prefix(length)) }
    @inlinable func right(_ length: Int) -> String { String(self.suffix(length)) }
}

extension Dictionary {
    @inlinable mutating func getOrSet(_ key: Key, _ defaultValue: () -> Value) -> Value {
        if let stored = self[key] { return stored }
        else {
            let newValue = defaultValue()
            self[key] = newValue
            return newValue
        }
    }
    @inlinable mutating func getOrElse(_ key: Key, _ defaultValue: () -> Value) -> Value {
        if let stored = self[key] { return stored } else { return defaultValue() }
    }
    @inlinable func containsKey(_ key: Key) -> Bool { self.keys.contains(key) }
}

extension Set {
    static func += (left: inout Set<Element>, right: Element) { left.insert(right) }
    static func -= (left: inout Set<Element>, right: Element) { left.remove(right) }
}

extension Array {
    static func += (left: inout Array<Element>, right: Element) { left.append(right) }
    init(_ size: Int, _ initValue: ((Int) -> Element)) {
        self = [Element]()
        for index in 0 ..< size {
            let value = initValue(index)
            self.append(value)
        }
    }
    init(_ size: Int, _ initValue: (() -> Element)) {
        self = [Element]()
        for _ in 0 ..< size {
            let value = initValue()
            self.append(value)
        }
    }
}
typealias IntArray = Array<Int>
typealias DoubleArray = Array<Double>
typealias BoolArray = Array<Bool>
typealias StringArray = Array<String>

extension Array where Element == Int {
    init(_ size: Int) {
        self = [Element](repeating: 0, count: size)
    }
}
extension Array where Element == Double {
    init(_ size: Int) {
        self = [Element](repeating: 0.0, count: size)
    }
}
extension Array where Element == Bool {
    init(_ size: Int) {
        self = [Element](repeating: false, count: size)
    }
}
extension Array where Element == String {
    init(_ size: Int) {
        self = [Element](repeating: "", count: size)
    }
}

extension Array {
    @inlinable func count(_ predicate: ((Element) -> Bool)) -> Int {
        var cnt = 0; for e in self { if (predicate(e)) { cnt += 1 } }
        return cnt
    }
    @inlinable func groupBy<K>(_ keySelector: (Element) -> K) -> [K : [Element]] {
        var destination = [K : [Element]]()
        for element in self {
            let key = keySelector(element)
            var list = destination.getOrSet(key) { [Element]() }
            list.append(element)
            destination[key] = list
        }
        return destination
    }
    @inlinable func groupByIndexed<K>(_ keySelector: (Element) -> K) -> [K : [Int]] {
        var destination = [K : [Int]]()
        for element in self.enumerated() {
            let key = keySelector(element.element)
            var list = destination.getOrSet(key) { [Int]() }
            list.append(element.offset)
            destination[key] = list
        }
        return destination
    }
}

extension Array {
    func binarySearch(_ element: Element, by compare: (Element, Element) -> Int, fromIndex: Int = 0, toIndex: Int = -1) -> Int {
        var low = fromIndex
        var high = (toIndex == -1) ? self.count - 1 : toIndex - 1
        while (low <= high) {
            let mid = (low + high) >> 1 // safe from overflows
            let midVal = self[mid]
            let cmp = compare(midVal, element)
            if (cmp < 0) { low = mid + 1 }          //-1
            else if (0 < cmp) { high = mid - 1 }    // 1
            else { return mid } // key found        // 0
        }
        return -(low + 1)  // key not found
    }
}
extension Array where Element : Comparable {
    func binarySearch(_ element: Element, fromIndex: Int = 0, toIndex: Int = -1) -> Int {
        var low = fromIndex
        var high = (toIndex == -1) ? self.count - 1 : toIndex - 1
        while (low <= high) {
            let mid = (low + high) >> 1 // safe from overflows
            let midVal = self[mid]
            if (midVal < element) { low = mid + 1 }
            else if (midVal > element) { high = mid - 1 }
            else { return mid } // key found
        }
        return -(low + 1)  // key not found
    }
}

extension Array where Element == Int {
    @inlinable func distinct() -> [Element] {
        var set = Set<Element>(), ary = [Element]()
        for n in self.indices { if !set.contains(self[n]) { ary.append(self[n]); set.insert(self[n]) } }
        return ary
    }
    @inlinable func any(_ predicate: (Element) -> Bool) -> Bool {
        var any = false; for element in self { if predicate(element) { any = true } }
        return any
    }
    @inlinable func all(_ predicate: (Element) -> Bool) -> Bool {
        self.allSatisfy(predicate)
    }
    @inlinable func sum() -> Element { self.reduce(0, +) }
    @inlinable func sum(by predicate: (Element) -> Element) -> Element {
        var sum = 0; for e in self { sum += predicate(e) }
        return sum
    }
    @inlinable func joinToString(_ sepatator: String = " ") -> String { self.map { String($0) }.joined(separator: sepatator) }
}

extension Array where Element == Double {
    @inlinable func sum() -> Element { self.reduce(0.0, +) }
    @inlinable func sum(by predicate: (Element) -> Element) -> Element {
        var sum = 0.0; for e in self { sum += predicate(e) }
        return sum
    }
    @inlinable func joinToString(_ sepatator: String = " ") -> String { self.map { String($0) }.joined(separator: sepatator) }
}
extension Array where Element == String {
    @inlinable func toIntDouble() -> (Int, Double) { (Int(self[0])!, Double(self[1])!) }
    @inlinable func toIntString() -> (Int, String) { (Int(self[0])!, self[1]) }
    @inlinable func toIntIntString() -> (Int, Int, String) { (Int(self[0])!, Int(self[1])!, self[2]) }
}

@inlinable func repeate(_ times1: Int, _ action: () -> Void) {
    for _ in 0 ..< times1 { action() }
}
@inlinable func repeate(_ times1: Int, _ action: (Int) -> Void) {
    for index1 in 0 ..< times1 {
        action(index1)
    }
}
@inlinable func repeate(_ times1: Int, _ times2: Int, _ action: (Int, Int) -> Void) {
    for index1 in 0 ..< times1 {
        for index2 in 0 ..< times2 {
            action(index1, index2)
        }
    }
}
@inlinable func repeate(_ times1: Int, _ times2: Int, _ times3: Int, _ action: (Int, Int, Int) -> Void) {
    for index1 in 0 ..< times1 {
        for index2 in 0 ..< times2 {
            for index3 in 0 ..< times3 {
                action(index1, index2, index3)
            }
        }
    }
}
@inlinable func repeate(_ times1: Int, _ times2: Int, _ times3: Int, _ times4: Int, _ action: (Int, Int, Int, Int) -> Void) {
    for index1 in 0 ..< times1 {
        for index2 in 0 ..< times2 {
            for index3 in 0 ..< times3 {
                for index4 in 0 ..< times4 {
                    action(index1, index2, index3, index4)
                }
            }
        }
    }
}

func measureTimeSeconds(block: (() -> Void)) -> Double {
    let startTime = Date()
    block()
    let duration = -startTime.timeIntervalSinceNow
    return duration
}

extension Array {
    func permutation (_ length: Int) -> [[Element]] {
        if length < 0 || length > self.count {
            return []
        } else if length == 0 {
            return [[]]
        } else {
            var permutations: [[Element]] = []
            let combinations = combination(length)
            for combination in combinations {
                var endArray: [[Element]] = []
                var mutableCombination = combination
                permutations += self.permutationHelper(length, array: &mutableCombination, endArray: &endArray)
            }
            return permutations
        }
    }
    private func permutationHelper(_ n: Int, array: inout [Element], endArray: inout [[Element]]) -> [[Element]] {
        if n == 1 {
            endArray += [array]
        }
        for i in 0  ..< n {
            _ = permutationHelper(n - 1, array: &array, endArray: &endArray)
            let j = n % 2 == 0 ? i : 0
            let temp: Element = array[j]
            array[j] = array[n - 1]
            array[n - 1] = temp
        }
        return endArray
    }
    /**
     - parameter length:
     - returns: Returns all of the combinations in the array of the given length
     */
    func combination (_ length: Int) -> [[Element]] {
        if length < 0 || length > self.count {
            return []
        }
        var indexes: [Int] = (0..<length).reduce([]) {$0 + [$1]}
        var combinations: [[Element]] = []
        let offset = self.count - indexes.count
        while true {
            var combination: [Element] = []
            for index in indexes {
                combination.append(self[index])
            }
            combinations.append(combination)
            var i = indexes.count - 1
            while i >= 0 && indexes[i] == i + offset {
                i -= 1
            }
            if i < 0 {
                break
            }
            i += 1
            let start = indexes[i-1] + 1
            for j in (i-1)..<indexes.count {
                indexes[j] = start + j - i + 1
            }
        }
        return combinations
    }
    /**
     - parameter length: The length of each permutations
     - returns: All of the permutations of this array of a given length, allowing repeats
     */
    func repeatedPermutation(_ length: Int) -> [[Element]] {
        if length < 1 {
            return []
        }
        var indexes: [[Int]] = []
        indexes.repeatedPermutationHelper([], length: length, arrayLength: self.count, indexes: &indexes)
        return indexes.map({ $0.map({ i in self[i] }) })
    }
    private func repeatedPermutationHelper(_ seed: [Int], length: Int, arrayLength: Int, indexes: inout [[Int]]) {
        if seed.count == length {
            indexes.append(seed)
            return
        }
        for i in (0..<arrayLength) {
            var newSeed: [Int] = seed
            newSeed.append(i)
            self.repeatedPermutationHelper(newSeed, length: length, arrayLength: arrayLength, indexes: &indexes)
        }
    }
}


import Foundation
let main: () = {

    let (N, M) = *listOfInt()
    let H = listOfInt()
    var G = [[Int]](repeating: [Int](), count: N)
    repeate(M) { m in
        let (A, B) = *listOfInt(-1, -1)
        G[A].append(B)
        G[B].append(A)
    }
    var ans = 0
    G.enumerated().forEach { g in
        let h = H[g.offset]
        if g.element.count == 0 { ans += 1 }
        else {
            var hier = 0
            g.element.forEach {
                if hier < H[$0] { hier = H[$0] }
            }

            if h > hier  { ans += 1 }
        }
    }

    print(ans)
}()

//----------------------------------

let dx = [1, 0, -1, 0] //[1, 0, -1, 0, -1,  1, -1, 1]
let dy = [0, 1, 0, -1] //[0, 1, 0, -1, -1, -1,  1, 1]

@inlinable func gcd(_ a: Int, _ b: Int) -> Int { (b > 0) ? gcd(b, a % b) : a }
@inlinable func lcm(_ a: Int, _ b: Int) -> Int { a / gcd(a, b) * b }

//----------------------------------

infix operator  =~ : ComparisonPrecedence
infix operator !=~ : ComparisonPrecedence
func =~ <T: FixedWidthInteger>(left: T, right: Range<T>) -> Bool { right ~= left }
func !=~ <T: FixedWidthInteger>(left: T, right: Range<T>) -> Bool { !(right ~= left) }
func =~ <T: FixedWidthInteger>(left: T, right: ClosedRange<T>) -> Bool { right ~= left }
func !=~ <T: FixedWidthInteger>(left: T, right: ClosedRange<T>) -> Bool { !(right ~= left) }

func =~ <T: Collection > (left: T.Element, right: T) -> Bool where T.Element : Equatable { right.contains(left) }
func !=~ <T: Collection > (left: T.Element, right: T) -> Bool where T.Element : Equatable { !right.contains(left) }

infix operator /^ : MultiplicationPrecedence
infix operator /^= : AssignmentPrecedence
func /^ <T: FixedWidthInteger>(left: T, right: T) -> T { (left + (right - 1)) / right }
func /^= <T: FixedWidthInteger>(left: inout T, right: T) { left = (left + (right - 1)) / right }

@inlinable func chmax<T: Comparable>(_ m: inout T, _ q: T) { if (m < q) { m = q } }
@inlinable func chmin<T: Comparable>(_ m: inout T, _ q: T) { if (m > q) { m = q } }
@inlinable func chRmax<T: Comparable>(_ m: inout T, _ q: T) -> Bool { if (m < q) { m = q; return true } else { return false } }
@inlinable func chRmin<T: Comparable>(_ m: inout T, _ q: T) -> Bool { if (m > q) { m = q; return true } else { return false } }

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) { (a[0], a[1]) }
prefix func * <T> (a: [T]) -> (T, T, T) { (a[0], a[1], a[2]) }
prefix func * <T> (a: [T]) -> (T, T, T, T) { (a[0], a[1], a[2], a[3]) }
prefix func * <T> (a: [T]) -> (T, T, T, T, T) { (a[0], a[1], a[2], a[3], a[4]) }
prefix func * <T> (a: [T]) -> (T, T, T, T, T, T) { (a[0], a[1], a[2], a[3], a[4], a[5]) }

func printErr(_ str: String, terminator: String = "\n") {
    let s = str + terminator
    FileHandle.standardError.write(s.data(using: .utf8)!)
    FileHandle.standardError.synchronizeFile()
}

@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func nextDouble() -> Double { Double(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt() -> [Int] { listOfString().map { Int($0)! } }
@inlinable func listOfInt(_ offset: Int = 0) -> [Int] { listOfString().map { Int($0)! + offset } }
@inlinable func listOfInt(_ offsets: Int ...) -> [Int] { listOfString().enumerated().map { Int($0.element)! + offsets[$0.offset % offsets.count] } }
@inlinable func listOfDouble(_ offset: Double = 0.0) -> [Double] { listOfString().map { Double($0)! + offset } }
@inlinable func listOfDouble(_ offsets: Double ...) -> [Double] { listOfString().enumerated().map { Double($0.element)! + offsets[$0.offset % offsets.count] } }

extension Int {
    init(s: String) { self.init(s)! }
    var isEven: Bool { self.isMultiple(of: 2) }
    var isOdd: Bool { !self.isEven }
    var isTrue: Bool { self != 0 }
    var isFalse: Bool { !self.isTrue }
    var toString: String { String(self) }
    var toChar: Character { Character(UnicodeScalar(UInt8(self))) }
}
func + (left: Int, right: Bool) -> Int { left + (right ? 1 : 0) }
extension Character {
    var asciiCode: Int { Int(self.asciiValue!) }
    var string: String { String(self) }
}
extension String {
    @inlinable subscript (position: Int) -> Character { self[self.index(self.startIndex, offsetBy: position)] }
    @inlinable func repeate(_ times: Int) -> String { String(repeating: self, count: times) }
    //  @inlinable subscript (n: Int) -> String { String(self[self.index(self.startIndex, offsetBy: n)]) }
    //  @inlinable subscript (n: Int) -> Int { Int(self[self.index(self.startIndex, offsetBy: n)].asciiValue!) }
    var toInt: Int { Int(self)! }
}
extension String { // VB like
    @inlinable func _index(_ position: Int) -> String.Index! {
        if !(0 ..< self.count ~= position) { return nil }
        return self.index(self.startIndex, offsetBy: position)
    }
    @inlinable func mid(from index: Int, length: Int) -> String! {
        if let startPosition = self._index(index) {
            if let endPosition = self._index(index + length - 1) {
                return String(self[startPosition...endPosition])
            } else {
                let endPosition = self.index(before: self.endIndex)
                return String(self[startPosition...endPosition])
            }
        }
        return ""
    }
    @inlinable func left(_ length: Int) -> String { String(self.prefix(length)) }
    @inlinable func right(_ length: Int) -> String { String(self.suffix(length)) }
}

extension Dictionary {
    @inlinable mutating func getOrSet(_ key: Key, _ defaultValue: () -> Value) -> Value {
        if let stored = self[key] { return stored }
        else {
            let newValue = defaultValue()
            self[key] = newValue
            return newValue
        }
    }
    @inlinable mutating func getOrElse(_ key: Key, _ defaultValue: () -> Value) -> Value {
        if let stored = self[key] { return stored } else { return defaultValue() }
    }
    @inlinable func containsKey(_ key: Key) -> Bool { self.keys.contains(key) }
}

extension Set {
    static func += (left: inout Set<Element>, right: Element) { left.insert(right) }
    static func -= (left: inout Set<Element>, right: Element) { left.remove(right) }
}

extension Array {
    static func += (left: inout Array<Element>, right: Element) { left.append(right) }
    init(_ size: Int, _ initValue: ((Int) -> Element)) {
        self = [Element]()
        for index in 0 ..< size {
            let value = initValue(index)
            self.append(value)
        }
    }
    init(_ size: Int, _ initValue: (() -> Element)) {
        self = [Element]()
        for _ in 0 ..< size {
            let value = initValue()
            self.append(value)
        }
    }
}
typealias IntArray = Array<Int>
typealias DoubleArray = Array<Double>
typealias BoolArray = Array<Bool>
typealias StringArray = Array<String>

extension Array where Element == Int {
    init(_ size: Int) {
        self = [Element](repeating: 0, count: size)
    }
}
extension Array where Element == Double {
    init(_ size: Int) {
        self = [Element](repeating: 0.0, count: size)
    }
}
extension Array where Element == Bool {
    init(_ size: Int) {
        self = [Element](repeating: false, count: size)
    }
}
extension Array where Element == String {
    init(_ size: Int) {
        self = [Element](repeating: "", count: size)
    }
}

extension Array {
    @inlinable func count(_ predicate: ((Element) -> Bool)) -> Int {
        var cnt = 0; for e in self { if (predicate(e)) { cnt += 1 } }
        return cnt
    }
    @inlinable func groupBy<K>(_ keySelector: (Element) -> K) -> [K : [Element]] {
        var destination = [K : [Element]]()
        for element in self {
            let key = keySelector(element)
            var list = destination.getOrSet(key) { [Element]() }
            list.append(element)
            destination[key] = list
        }
        return destination
    }
    @inlinable func groupByIndexed<K>(_ keySelector: (Element) -> K) -> [K : [Int]] {
        var destination = [K : [Int]]()
        for element in self.enumerated() {
            let key = keySelector(element.element)
            var list = destination.getOrSet(key) { [Int]() }
            list.append(element.offset)
            destination[key] = list
        }
        return destination
    }
}

extension Array {
    func binarySearch(_ element: Element, by compare: (Element, Element) -> Int, fromIndex: Int = 0, toIndex: Int = -1) -> Int {
        var low = fromIndex
        var high = (toIndex == -1) ? self.count - 1 : toIndex - 1
        while (low <= high) {
            let mid = (low + high) >> 1 // safe from overflows
            let midVal = self[mid]
            let cmp = compare(midVal, element)
            if (cmp < 0) { low = mid + 1 }          //-1
            else if (0 < cmp) { high = mid - 1 }    // 1
            else { return mid } // key found        // 0
        }
        return -(low + 1)  // key not found
    }
}
extension Array where Element : Comparable {
    func binarySearch(_ element: Element, fromIndex: Int = 0, toIndex: Int = -1) -> Int {
        var low = fromIndex
        var high = (toIndex == -1) ? self.count - 1 : toIndex - 1
        while (low <= high) {
            let mid = (low + high) >> 1 // safe from overflows
            let midVal = self[mid]
            if (midVal < element) { low = mid + 1 }
            else if (midVal > element) { high = mid - 1 }
            else { return mid } // key found
        }
        return -(low + 1)  // key not found
    }
}

extension Array where Element == Int {
    @inlinable func distinct() -> [Element] {
        var set = Set<Element>(), ary = [Element]()
        for n in self.indices { if !set.contains(self[n]) { ary.append(self[n]); set.insert(self[n]) } }
        return ary
    }
    @inlinable func any(_ predicate: (Element) -> Bool) -> Bool {
        var any = false; for element in self { if predicate(element) { any = true } }
        return any
    }
    @inlinable func all(_ predicate: (Element) -> Bool) -> Bool {
        self.allSatisfy(predicate)
    }
    @inlinable func sum() -> Element { self.reduce(0, +) }
    @inlinable func sum(by predicate: (Element) -> Element) -> Element {
        var sum = 0; for e in self { sum += predicate(e) }
        return sum
    }
    @inlinable func joinToString(_ sepatator: String = " ") -> String { self.map { String($0) }.joined(separator: sepatator) }
}

extension Array where Element == Double {
    @inlinable func sum() -> Element { self.reduce(0.0, +) }
    @inlinable func sum(by predicate: (Element) -> Element) -> Element {
        var sum = 0.0; for e in self { sum += predicate(e) }
        return sum
    }
    @inlinable func joinToString(_ sepatator: String = " ") -> String { self.map { String($0) }.joined(separator: sepatator) }
}
extension Array where Element == String {
    @inlinable func toIntDouble() -> (Int, Double) { (Int(self[0])!, Double(self[1])!) }
    @inlinable func toIntString() -> (Int, String) { (Int(self[0])!, self[1]) }
    @inlinable func toIntIntString() -> (Int, Int, String) { (Int(self[0])!, Int(self[1])!, self[2]) }
}

@inlinable func repeate(_ times1: Int, _ action: () -> Void) {
    for _ in 0 ..< times1 { action() }
}
@inlinable func repeate(_ times1: Int, _ action: (Int) -> Void) {
    for index1 in 0 ..< times1 {
        action(index1)
    }
}
@inlinable func repeate(_ times1: Int, _ times2: Int, _ action: (Int, Int) -> Void) {
    for index1 in 0 ..< times1 {
        for index2 in 0 ..< times2 {
            action(index1, index2)
        }
    }
}
@inlinable func repeate(_ times1: Int, _ times2: Int, _ times3: Int, _ action: (Int, Int, Int) -> Void) {
    for index1 in 0 ..< times1 {
        for index2 in 0 ..< times2 {
            for index3 in 0 ..< times3 {
                action(index1, index2, index3)
            }
        }
    }
}
@inlinable func repeate(_ times1: Int, _ times2: Int, _ times3: Int, _ times4: Int, _ action: (Int, Int, Int, Int) -> Void) {
    for index1 in 0 ..< times1 {
        for index2 in 0 ..< times2 {
            for index3 in 0 ..< times3 {
                for index4 in 0 ..< times4 {
                    action(index1, index2, index3, index4)
                }
            }
        }
    }
}

func measureTimeSeconds(block: (() -> Void)) -> Double {
    let startTime = Date()
    block()
    let duration = -startTime.timeIntervalSinceNow
    return duration
}

extension Array {
    func permutation (_ length: Int) -> [[Element]] {
        if length < 0 || length > self.count {
            return []
        } else if length == 0 {
            return [[]]
        } else {
            var permutations: [[Element]] = []
            let combinations = combination(length)
            for combination in combinations {
                var endArray: [[Element]] = []
                var mutableCombination = combination
                permutations += self.permutationHelper(length, array: &mutableCombination, endArray: &endArray)
            }
            return permutations
        }
    }
    private func permutationHelper(_ n: Int, array: inout [Element], endArray: inout [[Element]]) -> [[Element]] {
        if n == 1 {
            endArray += [array]
        }
        for i in 0  ..< n {
            _ = permutationHelper(n - 1, array: &array, endArray: &endArray)
            let j = n % 2 == 0 ? i : 0
            let temp: Element = array[j]
            array[j] = array[n - 1]
            array[n - 1] = temp
        }
        return endArray
    }
    /**
     - parameter length:
     - returns: Returns all of the combinations in the array of the given length
     */
    func combination (_ length: Int) -> [[Element]] {
        if length < 0 || length > self.count {
            return []
        }
        var indexes: [Int] = (0..<length).reduce([]) {$0 + [$1]}
        var combinations: [[Element]] = []
        let offset = self.count - indexes.count
        while true {
            var combination: [Element] = []
            for index in indexes {
                combination.append(self[index])
            }
            combinations.append(combination)
            var i = indexes.count - 1
            while i >= 0 && indexes[i] == i + offset {
                i -= 1
            }
            if i < 0 {
                break
            }
            i += 1
            let start = indexes[i-1] + 1
            for j in (i-1)..<indexes.count {
                indexes[j] = start + j - i + 1
            }
        }
        return combinations
    }
    /**
     - parameter length: The length of each permutations
     - returns: All of the permutations of this array of a given length, allowing repeats
     */
    func repeatedPermutation(_ length: Int) -> [[Element]] {
        if length < 1 {
            return []
        }
        var indexes: [[Int]] = []
        indexes.repeatedPermutationHelper([], length: length, arrayLength: self.count, indexes: &indexes)
        return indexes.map({ $0.map({ i in self[i] }) })
    }
    private func repeatedPermutationHelper(_ seed: [Int], length: Int, arrayLength: Int, indexes: inout [[Int]]) {
        if seed.count == length {
            indexes.append(seed)
            return
        }
        for i in (0..<arrayLength) {
            var newSeed: [Int] = seed
            newSeed.append(i)
            self.repeatedPermutationHelper(newSeed, length: length, arrayLength: arrayLength, indexes: &indexes)
        }
    }
}


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)


// 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()


// 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()


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)


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);
}


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)


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;
}


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();
}


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'));


'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);


import math
from functools import reduce
_=input()
print(reduce(math.gcd,map(int,input().split())))


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()


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()


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)


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)


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()


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);
	}
}


import java.io.*;
import java.util.*;

class Main {
    public static void main(String args[]) throws IOException {
        Scan sc = new Scan();
        int n = sc.scanInt();
        int gcd = 0;
        for(int i = 0; i < n; ++i){
            int val = sc.scanInt();
            gcd = GCD(gcd, val);
        }
        System.out.println(gcd);
    }
    static int GCD(int a, int b){
        if(b==0)
            return a;
        return GCD(b, a%b);
    }
}

class Scan
{
    private byte[] buf=new byte[1024];
    private int index;
    private InputStream in;
    private int total;
    public Scan()
    {
        in=System.in;
    }
    public int scan()throws IOException
    {
        if(total<0)
        throw new InputMismatchException();
        if(index>=total)
        {
            index=0;
            total=in.read(buf);
            if(total<=0)
            return -1;
        }
        return buf[index++];
    }
    public char scanChar() throws IOException {
        int n = scan();
        while(isWhiteSpace(n))
            n=scan();
        return (char)n;
    }
    public int scanInt()throws IOException
    {
        int integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public long scanLong() throws IOException {
        long integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public double scanDouble()throws IOException
    {
        double doub=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n)&&n!='.')
        {
            if(n>='0'&&n<='9')
            {
                doub*=10;
                doub+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        if(n=='.')
        {
            n=scan();
            double temp=1;
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    temp/=10;
                    doub+=(n-'0')*temp;
                    n=scan();
                }
                else throw new InputMismatchException();
            }
        }
        return doub*neg;
    }
    public String scanString()throws IOException
    {
        StringBuilder sb=new StringBuilder();
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        while(!isWhiteSpace(n))
        {
            sb.append((char)n);
            n=scan();
        }
        return sb.toString();
    }
    public boolean isWhiteSpace(int n)
    {
        if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
        return true;
        return false;
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author prakharjain
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        CMonstersBattleRoyale solver = new CMonstersBattleRoyale();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMonstersBattleRoyale {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            long gcd = a[0];

            for (int i = 1; i < n; i++) {
                gcd = gcd(a[i], gcd);
            }

            out.println(gcd);

        }

        long gcd(long a, long b) {
            if (b == 0)
                return a;
            else
                return gcd(b, a % b);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        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 nextInt() {
            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 boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; ++i) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


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);
	}
}


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);
	}
}


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);
	}
}


#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;
}


#include <bits/stdc++.h>

class kin{
public:
	inline void open(FILE *,int);
	inline void close(void);
	inline void scan(void);
	inline kin &operator>(char &);
	inline kin &operator>(int &);
	inline kin &operator>(long long &);
	inline kin &operator>(double &);
	inline kin &operator>(long double &);
	inline kin &operator>(char *);
	template<class T>
	inline void get(T *,int);
private:
	FILE *fp;
	char *buf;
	int siz;
	int idx;
}in;

class kout{
public:
	inline void open(FILE *,int);
	inline void close(void);
	inline void print(void);
	inline kout &operator<(char);
	inline kout &operator<(int);
	inline kout &operator<(long long);
	inline kout &operator<(double);
	inline kout &operator<(long double);
	inline kout &operator<(const char *);
	template<class T>
	inline void put(T *,int,char,char);
private:
	FILE *fp;
	char *buf;
	int siz;
	int idx;
}out;

inline int gcd(int x,int y){
	int p=x>y?x:y,q=x<y?x:y;
	if(q==0) return p;
	int r=p%q;
	while(r){
		p=q;
		q=r;
		r=p%q;
	}
	return q;
}

int main(int argc,char **argv){
	in.open(stdin,512);
	out.open(stdout,512);
	in.scan();
	int n;
	in>n;
	int g=0;
	for(int i=0;i<n;++i){
		int a;
		in>a;
		g=gcd(a,g);
	}
	out<g<'\n';
	out.print();
	in.close();
	out.close();
	return 0;
}

inline void kin::open(FILE *fparg,int sizarg){
	fp=fparg;
	buf=new char[sizarg];
	siz=sizarg;
	idx=0;
	return;
}
inline void kin::close(void){
	fp=nullptr;
	delete[] buf;
	buf=nullptr;
	siz=0;
	idx=0;
	return;
}
inline void kin::scan(void){
	int readsiz=(int)std::fread((void *)buf,(std::size_t)1,(std::size_t)siz,fp);
	if(readsiz!=siz) buf[readsiz]='\x00';
	idx=0;
	return;
}
inline kin &kin::operator>(char &var){
	if(!buf[idx]){
		var='\x00';
		return *this;
	}
	var=buf[idx];
	if(++idx==siz) scan();
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(int &var){
	if(!buf[idx]){
		var=0;
		return *this;
	}
	int sign=-1;
	if(buf[idx]=='-'){
		sign=1;
		if(++idx==siz) scan();
	}
	var=0;
	while(buf[idx]>='0'){
		var=var*10-(int)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(long long &var){
	if(!buf[idx]){
		var=0LL;
		return *this;
	}
	long long sign=-1LL;
	if(buf[idx]=='-'){
		sign=1LL;
		if(++idx==siz) scan();
	};
	var=0LL;
	while(buf[idx]>='0'){
		var=var*10LL-(long long)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(double &var){
	if(!buf[idx]){
		var=0.0;
		return *this;
	}
	double sign=-1.0;
	if(buf[idx]=='-'){
		sign=1.0;
		if(++idx==siz) scan();
	}
	var=0.0;
	while(buf[idx]>='0'){
		var=var*10.0-(double)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	if(buf[idx]=='.'){
		if(++idx==siz) scan();
		double dig=1.0;
		while(buf[idx]>='0'){
			var-=(double)(buf[idx]-'0')*(dig/=10.0);
			if(++idx==siz) scan();
		}
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(long double &var){
	if(!buf[idx]){
		var=0.0L;
		return *this;
	}
	long double sign=-1.0L;
	if(buf[idx]=='-'){
		sign=1.0L;
		if(++idx==siz) scan();
	}
	var=0.0L;
	while(buf[idx]>='0'){
		var=var*10.0L-(long double)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	if(buf[idx]=='.'){
		if(++idx==siz) scan();
		long double dig=1.0L;
		while(buf[idx]>='0'){
			var-=(long double)(buf[idx]-'0')*(dig/=10.0L);
			if(++idx==siz) scan();
		}
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(char *str){
	if(!buf[idx]){
		str[0]='\x00';
		return *this;
	}
	int ptr=0;
	while(buf[idx]>='!'){
		str[ptr++]=buf[idx];
		if(++idx==siz) scan();
	}
	str[ptr]='\x00';
	if(++idx==siz) scan();
	return *this;
}
template<class T>
inline void kin::get(T *arr,int num){
	for(int i=0;i<num;++i) (*this)>arr[i];
	return;
}

inline void kout::open(FILE *fparg,int sizarg){
	fp=fparg;
	buf=new char[sizarg];
	siz=sizarg;
	idx=0;
	return;
}
inline void kout::close(void){
	fp=nullptr;
	delete[] buf;
	buf=nullptr;
	siz=0;
	idx=0;
	return;
}
inline void kout::print(void){
	std::fwrite((void *)buf,(std::size_t)1,(std::size_t)idx,fp);
	idx=0;
	return;
}
inline kout &kout::operator<(char val){
	buf[idx]=val;
	if(++idx==siz) print();
	return *this;
}
inline kout &kout::operator<(int val){
	if(val<0){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1;
	char dig[10];
	int ptr=0;
	do{
		int tmp=val/10;
		dig[ptr++]=(char)-(val-tmp*10)+'0';
		val=tmp;
	}while(val);
	while(ptr--){
		buf[idx]=dig[ptr];
		if(++idx==siz) print();
	}
	return *this;
}
inline kout &kout::operator<(long long val){
	if(val<0LL){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1LL;
	char dig[19];
	int ptr=0;
	do{
		long long tmp=val/10LL;
		dig[ptr++]=(char)-(val-tmp*10LL)+'0';
		val=tmp;
	}while(val);
	while(ptr--){
		buf[idx]=dig[ptr];
		if(++idx==siz) print();
	}
	return *this;
}
inline kout &kout::operator<(double val){
	if(val<0.0){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1.0;
	double dig=1.0;
	while(val/dig<=-10.0) dig*=10.0;
	int tmp;
	while(dig>=1.0){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(double)tmp*dig;
		dig/=10.0;
	}
	buf[idx]='.';
	if(++idx==siz) print();
	for(int i=0;i<12;++i){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(double)tmp*dig;
		dig/=10.0;
	}
	return *this;
}
inline kout &kout::operator<(long double val){
	if(val<0.0L){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1.0L;
	long double dig=1.0L;
	while(val/dig<=-10.0L) dig*=10.0L;
	int tmp;
	while(dig>=1.0L){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(long double)tmp*dig;
		dig/=10.0L;
	}
	buf[idx]='.';
	if(++idx==siz) print();
	for(int i=0;i<16;++i){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(long double)tmp*dig;
		dig/=10.0L;
	}
	return *this;
}
inline kout &kout::operator<(const char *str){
	for(int i=0;str[i];++i){
		buf[idx]=str[i];
		if(++idx==siz) print();
	}
	return *this;
}
template<class T>
inline void kout::put(T *arr,int num,char dlm,char end){
	--num;
	for(int i=0;i<num;++i) (*this)<arr[i]<dlm;
	(*this)<arr[num]<end;
	return;
}


#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);
}


#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;
}


#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;
}


#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;
}


#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]);

}


#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;
}


#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;
}


#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;
}


/*#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;
}


#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;
}


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());


"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()


"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'));


"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()


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());


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());


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)
}


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)
}