local DBG = false
function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end
function dbgpr_t(tbl)
    if DBG then
        dbgpr(tbl)
        for i,v in ipairs(tbl) do
            io.write("[dbg]")
            print(i,v)
        end
    end
end
function parse_table(N)
    local tbl = {}
    for i=1,N do
        table.insert(tbl, io.read("n"))
    end
    return tbl
end
function getline()
    local k = io.read("n")
    local tbl = parse_table(k)
    io.read("l")
    return tbl
end
function attack(hptbl)
    hptbl[2] = hptbl[2] % hptbl[1]
    if hptbl[2] == 0 then
        table.remove(hptbl, 2)
    end
    table.sort(hptbl)
end
function main()
    local n = io.read("n")
    io.read("l")
    local hptbl = parse_table(n)
    table.sort(hptbl)
    dbgpr_t(hptbl)
    while #hptbl > 1 do
        attack(hptbl)
        dbgpr_t(hptbl)
    end
    print(hptbl[1])
end
main()
