There is crazy man named P29892P. He always tries to do crazy things as he thinks. One day he invented a machine and named it as ANGEN. The ANGEN is used to perform range operations. The range operation means performing operations on range values from {L..R}. At any time it performs operations on values in between L to R.
ANGEN can perform following operations
U I V - Update the value present at I  with value V
A L R - Find the sum between range L and R
M L R - Find the maximum number between L and R
m L R - Find the minimum number between L and R
S L R - Find second maximum value in between L and R
s L R - Find second mimimum value in between L and R
If it is not possible perform operation ANGEN returns “NA” with out quotes.
For Invalid operations ANGEN returns “!!!” with out quotes.
Now P29892P challenging his friends and you too, to build his invention with yourown code. So it's your time to defeat P29892P by implementing his invention with your own ability. Let's go and solve the problem.

-----Input-----
Input description.
- The first line of the input contains an integer N denoting the number of integers. 
- The next line contains N space separated integers."
- The next line contains a single integer Q denoting the number of Questions.
-  The next Q lines contains T Question type , L and R.

-----Output-----
Print output for each question in separate line.

-----Constraints-----
Should contain all the constraints on the input data that you may have. Format it like:
- 1 ≤ N ≤ 100000
- 1 ≤ values[i] ≤ 1000000000
- 1 ≤ Q ≤ 10000
- T in { A..Z, a..z }
- 1 ≤ L ≤ R ≤ N

-----Example-----
Input:
6
1 2 5 3 10 6
6
A 1 5
M 1 3
m 5 6
s 3 6
U 1 7
S 1 2

Output:
21
5
6
5
2

-----Explanation-----
...

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "n= int(input())\na= [int(x) for x in input().split()]\nq= int(input())\nfor i in range(0,q):\n t= input().split()\n L=int(t[1])-1\n R=int(t[2])-1\n if L<0 or L>=len(a):\n  print('!!!')\n elif t[0]=='U':\n  a[L]=R\n elif R<0 or R>=len(a) or L>R:   \n  print('!!!')\n elif t[0]=='A':\n  print(sum(a[L:R+1]))\n elif t[0]=='M':\n  x=list(set(a[L:R+1]))\n  print(max(x))\n elif t[0]=='m':\n  x=list(set(a[L:R+1]))\n  x.remove(max(x))\n  try:\n   print(max(x))\n  except:\n   print('NA') \n elif t[0]=='S': \n  x=list(set(a[L:R+1]))\n  print(min(x))\n elif t[0]=='s':\n  x=list(set(a[L:R+1]))\n  x.remove(min(x))\n  try:\n   print(min(x))\n  except:\n   print('NA')\n else:\n  print('!!!') "
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14079