ICPC Central B

Xem PDF

Điểm: 1400 Thời gian: 1.0s Bộ nhớ: 256M Input: bàn phím Output: màn hình

Given array \(A\) consisting of \(n\) integers \(a_i\). Tuan wants to remove at most 1 element
in array \(A\) so that the product of all remaining elements in that array is the largest.
Please help Tuan do it!
You task is to calculate the product of all remaining elements in that array after
removed at most 1 element.

Input

  • The first line contains a positive integer \(n (2 \le n \le 1000)\).
  • Next line contains n integers ai separated by a space \(( -10 ^9 \le a_i \le 10^ 9 )\).

Output

  • Print the result of the problem. Since it may be too big, print it after taking modulo
    \(10^9+7\).

Example

Test 1

Input
4
4 2 3 5
Output
120
Note
  • Without dropping any elements, the product of 4 elements is 4 × 2 × 3 × 5 = 120.

Test 2

Input
5
-1 -2 -4 1 2
Output
16
Note
  • Remove -1, the product of the remaining 4 elements is -2 × (-4) × 1 × 2 = 16

Bình luận


  • 3
    minhtuanitk20    9:15 p.m. 8 Tháng 1, 2022 đã chỉnh sửa

    /


    • 0
      huyhau6a2    9:19 a.m. 9 Tháng 1, 2022

      đúng mà mình mới ac xong


      • 3
        minhtuanitk20    10:25 a.m. 9 Tháng 1, 2022

        ý mik là lúc mới ra nó ra một cái đề khác mình thử làm thì nó ra đúng xong cái lúc sau đề nó đổi lại thành đề mới ::))


        • 2
          huyhau6a2    10:34 a.m. 9 Tháng 1, 2022

          hmm ảo thật đêý

      2 bình luận nữa