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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define BOOST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define __FOR3(i, a, n, inc) for(int i = (a); (inc) > 0 ? i < (n) : i >= (n); i += (inc))
#define __FOR2(i, a, n) __FOR3(i, a, n, 1)
#define __FOR1(i, n) __FOR2(i, 0, n)
#define __FOR0(n) __FOR1(_, n)
#define X first
#define Y second
#define FOR(...) GET_MACRO(__VA_ARGS__, __FOR3, __FOR2, __FOR1, __FOR0)(__VA_ARGS__)
#define debug(...){cerr << #__VA_ARGS__ << " = "; _debug(__VA_ARGS__);}
template<typename T> void _debug(const T &x) {cerr<< "[ "<<x<<" ]\n ";}
template<typename T,typename... tail_types>inline void _debug(const T &x, tail_types... tail) {
cerr<<"["<<x<<"], ";_debug(tail...);}
template<typename T>T ceil(const T &x1, const T &x2){return 1 + (x1 - 1) / x2;}



bool cmpval(pll p1, pll p2){
    return p1.Y < p2.Y;
}

const int N = 5e5 + 7;
vector<pll> a;


int n;
bool ok(int idx){
    ll suma = a[idx].Y;

    FOR(i,n){
        if (i == idx) continue;
        if (suma > a[i].Y) suma += a[i].Y;
        else return false; 
    }
    return true;
    
}
int main(){
    BOOST;

    cin >> n;
    a.resize(n + 1);
    

    FOR(i,n){
        a[i].X = i;
        cin >> a[i].Y;
    }
    a[n] = {n, 1e17};
    sort(a.begin(), a.end(), cmpval);
   

    int l = 0, r = n;
    while (r - l - 1 > 0){
        int mid = (l + r) / 2;
        if (ok(mid)) r = mid;
        else l = mid;
    }
    if (ok(l)) r = l;
    else if (ok(l + 1)) r = l + 1;

    vector<bool> ok(n + 1);
    for (int i = r; i < n; i++){
        ok[a[i].X] = true;
    }
    FOR(i,n){
        if (ok[i]) cout << "T";
        else cout << "N";
    }
    cout << "\n";


}