1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>
#define fi first
#define sc second
#define forn(i,p,k) for(int i=(p);i<=(k);++i)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MM = 500013;
const int inf = 1e9+13;
int T[MM],C[MM];
int n;
bool Check(int ind) {
    int sum = T[ind];
    forn(i,0,n-1) if(i != ind) {
        if(sum > T[i]) {
            sum+=T[i];
            if(sum > inf)   return true;
        } else  return false;
    }
    return true;
}

int BinS(int p, int k) {
    if(p==k)    return T[p];
    int mid = (p+k)>>1;
    if(Check(mid))  return BinS(p,mid);
    return BinS(mid+1,k);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    forn(i,0,n-1) cin>>T[i];
    memcpy(C,T,n*sizeof(int));
    sort(T,T+n);
    T[n] = inf;
    int K = BinS(0,n);
    forn(i,0,n-1)  cout<<(C[i] >= K ? 'T' : 'N');
}