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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "bits/stdc++.h"
 
using namespace std;
 
template<typename _T> void _debug(const char *s, _T x){ cerr << s << " = " << x << "\n";}
template<typename _T, typename... R> void _debug(const char *s, _T x, R... r){ while(*s != ',') cerr << *s++; cerr << " = " << x << ", "; _debug(s + 1, r...);}
 
#define debug(...)	_debug(#__VA_ARGS__,  __VA_ARGS__);
 
#define sz(s)	int32_t(s.size())
 
using ll = long long;
using ld = long double;
 
#define int long long  

const int N = 5e5 + 5;

vector < int > arr;

bool good(int pos){
    int masa = arr[pos];
    for(int i = 0; i < sz(arr); i++){
        if(i == pos)    continue;
        if(arr[i] < masa) masa += arr[i];
        else return false;
    }
    return true;
}

int32_t main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;  cin >> n;
    for(int i = 0; i < n; i++){
        int a;  cin >> a;
        arr.push_back(a);
    }
    vector < int > new_arr = arr;
    sort(begin(arr), end(arr));
    int lo = 0, hi = n;
    while(hi - lo > 1){
        int mid = (lo + hi) / 2;
        if(!good(mid)){
            lo = mid;
        }else{
            hi = mid;
        }
    }
    // debug(lo, hi);
    int mini = INT_MAX;
    lo = max(0LL, lo - 5);    
    hi = min(hi + 5, n - 1);
    for(int i = lo; i <= hi; i++){
        if(good(i)) mini = min(mini, arr[i]);
    }
    // cout << minn << "\n";
    for(int i = 0; i < n; i++){
        if(new_arr[i] < mini)  cout << "N";
        else cout << "T";
    }
    cout << "\n";
    
}