C++, key observation + category discussion + difference array (sweep line)
\n/*\nkey observation:\n1. 2 <= sum <= 2e5, so it is possible to try every possible x\n2. then for one x, examine how many moves needs to be done in O(1)/O(logn
```\n/*\nkey observation:\n1. 2 <= sum <= 2e5, so it is possible to try every possible x\n2. then for one x, examine how many moves needs to be done in O(1)/O(logn), which is hard, since even we got below 5 intervals,\nwe still need to use O(n) to check which interval x falls and accumulate.\n3. This accumulate can be preprocessed using O(N) using difference array (sweep line).\n\n\n\n\nFor a pair i, j, \n    we have:\n    num[i], num[j]\n\n    let:\n    l = min(num[i], num[j])\n    mid = num[i] + num[j]\n    r = max(num[i], num[j]) \n\n    Then,\n    [2, l + 1) needs two moves\n    [l + 1, mid) needs one move\n    [m, mid + 1) needs zero move\n    [mid + 1, r + limit + 1) needs one move\n    [r + limit + 1, 2 * limit + 1) needs two move\n    \n    \n    \n    */\n\n\n\n\n\nconst int N = 2e5 + 10;\nclass Solution {\n    int diff[N] = {};\npublic:\n    int minMoves(vector<int>& arr, int limit) {\n        int n = arr.size();\n        int i = 0, j = n - 1;\n        while (i < j)\n        {\n            int l = min(arr[i], arr[j]);\n            int mid = arr[i] + arr[j];\n            int r = max(arr[i], arr[j]);\n\n            diff[2] += 2;\n            diff[l + 1] -= 2;\n            diff[l + 1] += 1;\n            diff[mid] -= 1;\n            diff[mid] += 0;\n            diff[mid + 1] -= 0;\n            diff[mid + 1] += 1;\n            diff[r + limit + 1] -= 1;\n            diff[r + limit + 1] += 2;\n            diff[2 * limit + 1] -= 2;\n            \n            i ++ ;\n            j -- ;\n        }\n        \n        for (int i = 1; i < N; ++ i)\n            diff[i] += diff[i - 1];\n        \n        return *min_element(diff + 2, diff + 2 * limit);\n    }\n};\n\n\n\n\n\n\n\n```
[]