Very Easy To Understand O(n) Java Solution
Input: [8,1,5,2,6]\nOutput: 11\nExplanation: i = 0, j = 2, A[i] + A[j] + i - j = 8 + 5 + 0 - 2 = 11\nI find the equation can rewrite from A[i] + A[j] + i - j to
Input: [8,1,5,2,6]\nOutput: 11\nExplanation: i = 0, j = 2, A[i] + A[j] + i - j = 8 + 5 + 0 - 2 = 11\nI find the equation can rewrite from ` A[i] + A[j] + i - j ` to ` (A[i] + i) + (A[j] - j) `\nSo in a one-pass loop, we can record the max `(A[i] + i) `  before, and calculate the possible result `res`.\n\n```\nclass Solution {\n    public int maxScoreSightseeingPair(int[] A) {\n        int max = A[0];\n        int res = Integer.MIN_VALUE;\n        for(int i = 1; i < A.length; ++i){\n            res = Math.max(res, max + A[i] -i);\n            max = Math.max(max, A[i] +i);\n        }\n        \n        return res;\n    }\n}\n```
[]