#include <iostream>
#include <vector>
using namespace std;


long long maxmin(const vector<long long>& V);


int main() {
  int n;
  while (cin >> n) {
    vector<long long> V(n);
    for (auto& x : V) cin >> x;

    int q;
    cin >> q;
    cout << "----" << '\n';
    while (q--) {
      int i;
      long long x;
      cin >> i >> x;
      long long y = V[i];
      V[i] = x;
      cout << maxmin(V) << '\n';
      V[i] = y;
    }
  }
  return 0;
}
