We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Advanced
  4. Find Maximum Index Product

Find Maximum Index Product

Problem
Submissions
Leaderboard
Discussions
Editorial
  1. Prepare
  2. Data Structures
  3. Advanced
  4. Find Maximum Index Product
Exit Full Screen View
  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

You are given a list of numbers . For each element at position (), we define and as:
= closest index j such that j < i and . If no such j exists then = 0.
= closest index k such that k > i and . If no such k exists then = 0.

We define = * . You need to find out the maximum among all i.

Input Format

The first line contains an integer , the number of integers. The next line contains the integers describing the list a[1..N].

Constraints


Output Format

Output the maximum among all indices from to .

Sample Input

5
5 4 3 4 5

Sample Output

8

Explanation

We can compute the following:





The largest of these is 8, so it is the answer.

  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy