function problem_c(id, pr, n, a):
    sz := (n + 1 + 63) / 64
    bs := array(sz)
    bnd := sz * 64

    i := id

    while i < n:
        x := a[i]
        if x < bnd:
            bs[x / 64] |= 1 << (x % 64)
        i += pr

    left := 2 * id + 1
    right := left + 1

    if left < pr:
        for i := 0 until sz:
            bs[i] |= receive(left)
    if right < pr:
        for i := 0 until sz:
            bs[i] |= receive(right)

    if id != 0:
        for i := 0 until sz:
            send((id - 1) / 2, bs[i])
    else:
        continue := 1
        i := 0

        while continue:
            if bs[i] == -1:
                i += 1
            else:
                continue := 0

        j := 0
        continue := 1

        while continue:
            if (bs[i] & (1 << j)) != 0:
                j += 1
            else:
                continue := 0

        print(i * 64 + j)
