import copy

# a = get_int()
def get_int():
    return int(input())

# a = get_string()
def get_string():
    return input()

# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]

# a_list = get_string_list():
def get_string_list():
    return input().split()

# a, b = get_int_multi()
def get_int_multi():  # a, b = get_int_multi()
    return map(int, input().split())

# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    n, k = get_int_multi()
    a_list = get_int_list()

    p_list=[]
    m_list=[]
    z_list=[]
    for num in a_list:
        if num > 0:
            p_list.append(num)
        elif num < 0:
            m_list.append(num)
        else:
            z_list.append(num)

    p_list.sort(reverse=True)
    m_list.sort()


    if k % 2 == 1:
        if (len(p_list) > 0):
            ans = p_list[0]
            del p_list[0]
            k -= 1
        elif len(z_list) > 0:
            ans = 0
            del z_list[0]
            k -= 1
        else:
            ans = m_list[len(m_list) -1]
            del m_list[len(m_list) -1]
            k -= 1
            m_list.sort(reverse=True)

    else:
        ans = 1

    nokori = k
    while nokori > 0:

        if nokori == 1 and len(p_list) > 0:
            ans = ans * p_list[0]
            del p_list[0]
        elif nokori == 1 and len(z_list) > 0:
            ans = 0
        elif nokori == 1 :
            ans = ans * m_list[0]
            del m_list[0]

        elif len(p_list) == 1 and len(p_list) == 1 and len(z_list) > 0:
            ans = 0
            nokori -= 2
        elif len(p_list) == 1 and len(p_list) == 1 and len(z_list) == 0:
            ans = ans * p_list[0] * m_list[len(m_list) -1]
            del p_list[0]
            del m_list[0]
            nokori -= 2
        else:
            if len(p_list) >= 2:
                pval = p_list[0] * p_list[1]
            else:
                pval = 0

            if len(m_list) >= 2:
                mval = m_list[0] * m_list[1]
            else:
                mval = 0

            if pval > mval:
                del p_list[0]
                del p_list[0]
                ans = ans * pval
            else:
                del m_list[0]
                del m_list[0]
                ans = ans * mval
            nokori -= 2

    print(ans % 1000000007)

if __name__ == '__main__':
    main()




### FIXED CODE ###

import copy

# a = get_int()
def get_int():
    return int(input())

# a = get_string()
def get_string():
    return input()

# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]

# a_list = get_string_list():
def get_string_list():
    return input().split()

# a, b = get_int_multi()
def get_int_multi():  # a, b = get_int_multi()
    return map(int, input().split())

# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    n, k = get_int_multi()
    a_list = get_int_list()

    p_list=[]
    m_list=[]
    for num in a_list:
        if num > 0:
            p_list.append(num)
        else :
            m_list.append(num)


    p_list.sort()
    m_list.sort(reverse=True)


    if k % 2 == 1:
        if (len(p_list) > 0):
            ans = p_list.pop()
            k -= 1
        else:
            m_list.sort()
            ans = m_list.pop()
            k -= 1
    else:
        ans = 1

    nokori = k
    while nokori > 0:
        if len(p_list) == 1 and len(m_list) == 1:
            ans = ans * p_list.pop() * m_list[0]
            del m_list[0]
            nokori -= 2
        else:
            if len(p_list) >= 2:
                pval = p_list[-1] * p_list[-2]
            else:
                pval = 0

            if len(m_list) >= 2:
                mval = m_list[-1] * m_list[-2]
            else:
                mval = 0

            if pval > mval:
                p_list.pop()
                p_list.pop()
                ans = ans * pval % 1000000007
            else:
                m_list.pop()
                m_list.pop()
                ans = ans * mval % 1000000007
            nokori -= 2

    print(ans % 1000000007)

if __name__ == '__main__':
    main()