Problem:
Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers.  She thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of **distinct** positive integers is called **special** if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is **not** 1.  Nagase wants to find a **special** set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a **special** set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.

Incorrect submission (verdict: Wrong Answer):
def ans(N):
    ret = []
    cnt = 0
    if N % 2 == 0:
        summand = 6
        while summand <= 30000 - 6:
            ret.append(summand)
            cnt += 1
            summand += 6
            ret.append(summand)
            cnt += 1
            summand += 6
            if cnt == N:
                return " ".join(list(map(str, ret)))
        summand = 3
        while summand <= 30000 - 6:
            ret.append(summand)
            cnt += 1
            summand += 6
            ret.append(summand)
            cnt += 1
            summand += 6
            if cnt == N:
                return " ".join(list(map(str, ret)))
        summand = 2
        while summand <= 30000 - 2:
            ret.append(summand)
            cnt += 1
            summand += 2
            ret.append(summand)
            cnt += 1
            summand += 4
            if cnt == N:
                return " ".join(list(map(str, ret)))
    else:
        ret = [2, 4, 8]
        cnt = 3
        if N == 3:
            return " ".join(list(map(str, ret)))

        summand = 6
        while summand < 30000:
            ret.append(summand)
            cnt += 1
            summand += 6
            ret.append(summand)
            cnt += 1
            summand += 6
            if cnt == N:
                return " ".join(list(map(str, ret)))
        summand = 3
        while summand < 30000:
            ret.append(summand)
            cnt += 1
            summand += 6
            ret.append(summand)
            cnt += 1
            summand += 6
            if cnt == N:
                return " ".join(list(map(str, ret)))
        summand = 10
        while summand < 30000:
            ret.append(summand)
            cnt += 1
            summand += 4
            ret.append(summand)
            cnt += 1
            summand += 2
            if cnt == N:
                return " ".join(list(map(str, ret)))


N = int(input())
print(ans(N))

Fixed, accepted submission:
def ans(N):
    if N % 2 == 0:
        if N == 4:
            return "2 4 3 9"
        ret = [2, 4, 3, 9]
        cnt = 4
        summand = 6
        while summand <= 30000 - 6:
            ret.append(summand)
            cnt += 1
            summand += 6
            ret.append(summand)
            if summand > 30000:
                return "over 30000"
            cnt += 1
            summand += 6
            if cnt == N:
                return " ".join(list(map(str, ret)))
        summand = 15
        while summand <= 30000 - 6:
            ret.append(summand)
            cnt += 1
            summand += 6
            ret.append(summand)
            if summand > 30000:
                return "over 30000"
            cnt += 1
            summand += 6
            if cnt == N:
                return " ".join(list(map(str, ret)))
        summand = 8
        while summand <= 30000 - 2:
            ret.append(summand)
            cnt += 1
            summand += 2
            ret.append(summand)
            if summand > 30000:
                return "over 30000"
            cnt += 1
            summand += 4
            if cnt == N:
                return " ".join(list(map(str, ret)))
    else:
        if N == 19999:
            if N == 3:
                return "2 5 63"
            ret = [2, 8, 14]
            cnt = 3
            summand = 3
            while summand < 30000:
                ret.append(summand)
                cnt += 1
                summand += 6
                ret.append(summand)
                # if summand > 30000:
                #     return "over 30000"
                cnt += 1
                summand += 6
                if cnt == N:
                    return " ".join(list(map(str, ret)))
            summand = 12
            while summand <= 30000 - 6:
                ret.append(summand)
                cnt += 1
                summand += 6
                ret.append(summand)
                # if summand > 30000:
                #     return "over 30000"
                cnt += 1
                summand += 6
                if cnt == N:
                    return " ".join(list(map(str, ret)))
            ret.append(30000)
            cnt += 1
            summand = 20
            while summand < 30000:
                ret.append(summand)
                cnt += 1
                summand += 2
                ret.append(summand)
                # if summand > 30000:
                #     return "over 30000"
                cnt += 1
                summand += 4
                if cnt == N:
                    return " ".join(list(map(str, ret)))
            ret.append(4)
            cnt += 1
            if cnt == N:
                return " ".join(list(map(str, ret)))
            ret.append(10)
            cnt += 1
            if cnt == N:
                return " ".join(list(map(str, ret)))
            ret.append(16)
            cnt += 1
            if cnt == N:
                return " ".join(list(map(str, ret)))
        if N == 3:
            return "2 5 63"
        ret = [2, 8, 14]
        cnt = 3
        summand = 3
        while summand < 30000:
            ret.append(summand)
            cnt += 1
            summand += 6
            ret.append(summand)
            # if summand > 30000:
            #     return "over 30000"
            cnt += 1
            summand += 6
            if cnt == N:
                return " ".join(list(map(str, ret)))
        summand = 6
        while summand < 30000:
            ret.append(summand)
            cnt += 1
            summand += 6
            ret.append(summand)
            # if summand > 30000:
            #     return "over 30000"
            cnt += 1
            summand += 6
            if cnt == N:
                return " ".join(list(map(str, ret)))
        summand = 20
        while summand < 30000:
            ret.append(summand)
            cnt += 1
            summand += 2
            ret.append(summand)
            # if summand > 30000:
            #     return "over 30000"
            cnt += 1
            summand += 4
            if cnt == N:
                return " ".join(list(map(str, ret)))
        ret.append(4)
        cnt += 1
        if cnt == N:
            return " ".join(list(map(str, ret)))
        ret.append(10)
        cnt += 1
        if cnt == N:
            return " ".join(list(map(str, ret)))
        ret.append(16)
        cnt += 1
        if cnt == N:
            return " ".join(list(map(str, ret)))
        ret.remove(6)
        cnt += 1
        if cnt == N:
            return " ".join(list(map(str, ret)))


N = int(input())
print(ans(N))