Using Simple Segment Tree.
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    struct node {\n        long long lr, r, l, nlr;\n        node() {\n            lr = nlr = 0;\n            r = -1e9;\n            l = -1e9;\n        }\n    };\n\n    int mod = 1e9 + 7;\n    vector<struct node> tree;\n    vector<int> arr;\n\n    node merge(node a, node b) {\n        node c = node();\n        c.lr = max({a.l + b.r, a.lr + b.r, a.l + b.lr});\n        c.r = max({a.nlr + b.r, a.r + b.r, a.nlr + b.lr,b.r});\n        c.l = max({a.l + b.nlr, a.lr + b.nlr, a.l + b.l, a.l});\n        c.nlr = max({a.nlr+b.nlr, a.nlr + b.l, a.r + b.nlr,a.nlr});\n        return c;\n    }\n\n    void build(int index, int l, int r) {\n        if (l == r) {\n            tree[index] = node();\n            tree[index].lr = arr[l];\n            return;\n        }\n        int mid = l + (r - l) / 2;\n        build(2 * index, l, mid);\n        build(2 * index + 1, mid + 1, r);\n        tree[index] = merge(tree[2 * index], tree[2 * index + 1]);\n    }\n\n    void update(int index, int l, int r, int pos, int val) {\n        if (l == r) {\n            tree[index] = node();\n            tree[index].lr = val;\n            return;\n        }\n        int mid = l + (r - l) / 2;\n        if (pos <= mid) {\n            update(2 * index, l, mid, pos, val);\n        } else {\n            update(2 * index + 1, mid + 1, r, pos, val);\n        }\n        \n        tree[index] = merge(tree[2 * index], tree[2 * index + 1]);\n        //cout<<l<<" "<<r<<endl;\n        //cout<<max(tree[index].lr, max(tree[index].nlr, max(tree[index].l, tree[index].r)))<<endl;\n    }\n\n    int maximumSumSubsequence(vector<int>& nums, vector<vector<int>>& que) {\n        int n = nums.size();\n        tree.resize(4 * n);\n        arr = nums;\n        build(1, 0, n - 1);\n        int ans = 0;\n        for (int i = 0; i < que.size(); i++) {\n            update(1, 0, n - 1, que[i][0], que[i][1]);\n            ans = (ans + max(tree[1].lr, max(tree[1].nlr, max(tree[1].l, tree[1].r)))) % mod;\n        }\n        return ans;\n    }\n};\n\n```
['C++']