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 swap(tbl, i, j)
    local oldj = tbl[j]
    tbl[j] = tbl[i]
    tbl[i] = oldj
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 turn(hptbl)
    table.sort(hptbl)
    local minhp = hptbl[1]
    for i=2,#hptbl do
        hptbl[i] = hptbl[i] % minhp
    end
    next_tbl = {}
    for i=1,#hptbl do
        if hptbl[i] ~= 0 then
            table.insert(next_tbl, hptbl[i])
        end
    end
    table.sort(next_tbl)
    return next_tbl
end
function main()
    local n = io.read("n")
    io.read("l")
    local hptbl = parse_table(n)
    --dbgpr_t(hptbl)
    while #hptbl > 1 do
        hptbl = turn(hptbl)
        --dbgpr_t(hptbl)
    end
    print(hptbl[1])
end
main()
