def find_remainder(arr, lens, n):
    if n == 0:
        raise ZeroDivisionError("integer division or modulo by zero")
    result = 1 % n
    for i in range(min(lens, len(arr))):
        result = (result * (arr[i] % n)) % n
    return result