/// @author Camillus <3
#ifndef LOCAL
#define debug(...) 42
#endif
#include "bits/stdc++.h"
using namespace std;
namespace st {
static constexpr int size = 1 << 20;
int a[size];
int tree[size * 2 - 1];
inline int comp(int i, int j) {
if (a[i] > a[j]) {
return i;
} else {
return j;
}
}
void init() {
for (int i = 0; i < size; i++) {
int x = size + i - 1;
tree[x] = i;
}
for (int x = size - 2; x >= 0; x--) {
tree[x] = comp(tree[x * 2 + 1], tree[x * 2 + 2]);
}
}
inline void set(int i, int v) {
a[i] = v;
int x = size + i - 1;
while (x) {
x = (x - 1) >> 1;
tree[x] = comp(tree[x * 2 + 1], tree[x * 2 + 2]);
}
}
int get(int l, int r, int x = 0, int lx = 0, int rx = size) {
if (l >= rx || lx >= r) {
return 0;
}
if (l <= lx && rx <= r) {
return tree[x];
}
return comp(
get(l, r, x * 2 + 1, lx, (lx + rx) / 2),
get(l, r, x * 2 + 2, (lx + rx) / 2, rx)
);
}
} // namespace st
int n, k;
auto a = st::a;
set<tuple<int, int, int>, greater<>> b;
int get_left(int i) {
return st::get(i - k + 1, i);
}
int get_right(int i) {
return st::get(i - k + 1, i);
}
void add_rrr(int i) {
if (i != n) {
int j = get_right(i);
b.emplace(a[i] + a[j], i, j);
}
if (i != 1) {
int j = get_left(i);
b.emplace(a[i] + a[j], i, j);
}
}
void build() {
b.clear();
for (int i = 1; i <= n; i++) {
add_rrr(i);
}
}
int calc() {
while (true) {
auto [v, i, j] = *b.begin();
if (v != a[i] + a[j]) {
b.erase(b.begin());
b.emplace(a[i] + a[j], i, j);
} else {
return v;
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
st::init();
int q;
cin >> n >> k >> q;
int K = 1000;
auto a = st::a;
for (int i = 1; i <= n; i++) {
int v;
cin >> v;
st::set(i, v);
}
build();
cout << calc() << '\n';
for (int aa = 0; aa < q; aa++) {
int i, v;
cin >> i >> v;
st::set(i, v);
add_rrr(i);
if (i != n) {
int j = get_right();
add_rrr(j);
}
if (i != 1) {
int j = st::get(i - k + 1, i);
add_rrr(j);
}
// if (aa % K == 0) {
// build();
// }
cout << calc() << '\n';
}
return 0;
}