Well explained intuitive solution
\n/**\n * @param {number[]} values\n * @return {number}\n */\nvar maxScoreSightseeingPair = function(values) {\n    // Given formula is values[i] + values[j] + 
```\n/**\n * @param {number[]} values\n * @return {number}\n */\nvar maxScoreSightseeingPair = function(values) {\n    // Given formula is values[i] + values[j] + i - j;\n    // Break it as values[i] + i + values[j] - j;\n    \n    // take the first element of the pair with the formula values[i] + i for i = 0\n    let firstElementInPair = values[0] + 0;\n    \n    // final result;\n    let resultPairValue = 0;\n    \n    for(let i = 1; i < values.length; i++) {\n        \n        // values[i] + i is computed in firstElementInPair.\n        \n        // Compute secondElementInPair with the formula Values[j] - j for our current i;\n        const secondElementInPair = values[i] - i;\n        \n        // calculate the pairValue with the formula values[i] + i (FirstElementInPair) + values[j] - j (SecondElementInPair);\n        const currentPairValue = firstElementInPair + secondElementInPair;\n        \n        // keep the best pair found so far.\n        resultPairValue = Math.max(resultPairValue, currentPairValue);\n        \n        // update firstElementInPair, if any other better element is found\n        firstElementInPair = Math.max(firstElementInPair, values[i] + i);\n    }\n    return resultPairValue;\n};\n```
['JavaScript']