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
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")*/

#include <bits/stdc++.h>
#define bit(n, i) (((n)>>(i))&1)
#define cat(x) cout << #x << " = " << x << "\n"
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define inf 2000000000
#define llinf 2000000000000000000LL
#define forn(i, a, b) for(ll i = (a); i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
#define ppc(x) __builtin_popcount(x)
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int, int> i2;
typedef vector<int> vi;
typedef vector<ll> vll;

const int N = 5e5+9;
pair<ll, int> A[N];
bool ans[N];

int n;

bool king(int k) {
    ll s = A[k].fi;
    forn(i, 1, n) {
        if(i != k) {
            if(A[i].fi < s)
                s += A[i].fi;
            else
                return false;
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    forn(i, 1, n) {
        cin >> A[i].fi;
        A[i].se = i;
    }
    sort(A+1, A+n+1);
    A[0].fi = 0;
    A[n+1].se = inf;
    int lo = 0, hi = n+1;
    while(lo < hi) {
        int mid = (lo+hi)>>1;
        if(king(mid)) {
            hi = mid;
        }
        else {
            lo = mid+1;
        }
    }
    forn(i, lo, n) {
        ans[A[i].se] = true;
    }
    forn(i, 1, n) {
        cout << (ans[i] ? 'T' : 'N');
    }

    return 0;
}