Find largest product of longest subsequence between min and max Input:

A non-empty sequence of integers greater than zero, the length of which is greater than 1.

Output:

The largest product of all elements of the longest subsequence between the minimum and maximum elements of sequence including themselves.

Note:

Because the minimum and maximum elements can be repeated, then to a definite answer necessary to find the longest possible subsequence, at one end of which is a minimum and at the other end maximum elements of the sequence. If there is multiple longest subsequences then choose subsequence with largest product.

Examples:

1st example:

Input: [5, 7, 3, 2, 1, 2, 2, 7, 5]

Output: 42

Explanation:
min == 1, max == 7. There is 2 possible subsequences with min and max on ends: [1, 2, 2, 7] and  [7, 3, 2, 1]. Their length is equal, so comparing products: 7*3*2*1 == 42 and 1*2*2*7 == 28. Because 42 &gt;= 28, answer: 42.

2nd example:

Input: [1, 2, 2, 2, 4, 3, 3, 1]

Output: 32

Explanation: 
min == 1, max == 4. 2 subsequences: [1, 2, 2, 2, 4] and [4, 3, 3, 1]. Length of [1, 2, 2, 2, 4] is greater than length of [4, 3, 3, 1]. product: 1*2*2*2*4 == 32 => answer is 32.

3d example:

Input: [1, 2, 3, 4, 3, 3, 1]

Output: 36

Short explanation:
min == 1, max == 4. 2 subsequences: [1, 2, 3, 4] and [4, 3, 3, 1]. 1*2*3*4 == 24, 4*3*3*1 == 36, 36 &gt;= 24 => answer is 36.

4th example:

Input: [2, 2, 2]

Output: 8

Explanation: 
min == 2, max == 2. 2 different subsequences: [2, 2] and [2, 2, 2]. Length of [2, 2, 2] is greater than length of [2, 2]. product: 2*2*2 == 8 => answer is 8.

More (random) examples:

&gt;&gt;&gt;[7, 2, 3, 6, 8, 6, 2, 5, 4, 3]
288
&gt;&gt;&gt;[3, 3, 8, 9, 1, 7, 7, 2, 2, 4]
9
&gt;&gt;&gt;[3, 2, 6, 5, 4, 1, 8, 8, 7, 9]
4032
&gt;&gt;&gt;[7, 4, 2, 8, 8, 3, 9, 9, 5, 6]
31104


Check your solution:

Here is Python 3 lambda (788 bytes), which satisfies the requirement of the task:

lambda O: __import__('functools').reduce(__import__('operator').mul,O[[[slice(O.index(max(O)),len(O)-1-O[::-1].index(min(O))+1),slice(O.index(min(O)),(len(O)-1-O[::-1].index(max(O)))+1)][__import__('functools').reduce(__import__('operator').mul,O[O.index(min(O)):(len(O)-1-O[::-1].index(max(O)))+1],1)&gt;=__import__('functools').reduce(__import__('operator').mul,O[O.index(max(O)):len(O)-1-O[::-1].index(min(O))+1],1)],slice(O.index(min(O)),(len(O)-1-O[::-1].index(max(O)))+1),slice(O.index(max(O)),len(O)-1-O[::-1].index(min(O))+1)][(len(range(O.index(min(O)),(len(O)-1-O[::-1].index(max(O)))+1))&gt;len(range(O.index(max(O)),len(O)-1-O[::-1].index(min(O))+1)))-(len(range(O.index(min(O)),(len(O)-1-O[::-1].index(max(O)))+1))&lt;len(range(O.index(max(O)),len(O)-1-O[::-1].index(min(O))+1)))]],1)


Winner:

Shortest solution will win. All programming languages accepted.

P.S.: I will be happy to the explanations of your solutions
Jelly, 15 bytes

NMpMr/€LÐṀịµP€Ṁ


TryItOnline!

How?

NMpMr/€LÐṀịµP€Ṁ - Main link: list of integers, L
           µ    - links to the left as a monadic chain with argument L
N               - negate elements of L
 M              - indexes of maximal elements (i.e. indexes of minimal elements of L)
   M            - indexes of maximal elements of L
  p             - Cartesian product of the min and max indexes
     /€         - reduce each list (all of which are pairs) with the dyad:
    r           -     range(a,b)  (note if a&gt;b this is [a,a-1,...,b])
        ÐṀ      - filter keeping those with maximal
       L        -     length
          ị     - index into L (vectorises)   (get the values)
            P€  - product of a list for €ach
              Ṁ - maximum