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
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int,int>;
using vpii = vector<pii>;
using graph = vector<vi>;

#define FOR(name__, upper__) for (int name__ = 0; name__ < (upper__); ++name__)
#define all(x) begin(x), end(x)
#define mp make_pair
#define mt make_tuple

template<class T>
void initialize_matrix(vector<vector<T>>& matrix, int rows, int cols, T value) {
	assert(matrix.empty());
	FOR (row, rows) 
		matrix.emplace_back(cols, value);
}

void go() {
    int n; cin >> n;
    vpii A(n); for (auto &p : A) cin >> p.first;
    FOR (i, n) A[i].second = i;

    sort(all(A));

    vll P(n + 1, 0ll);
    FOR (i, n) P[i + 1] = P[i] + A[i].first;


    vi ans(n, 0);

    int i = 0;
    while (i < n && A[i].first == A[0].first) i++;

    int last = i;
    while (i < n) {
        if (P[i] <= A[i].first) last = i;
        i++;
    }

    for (int j = last; j < n; j++) ans[A[j].second] = 1;
    
    for (auto x : ans) cout << (x? 'T' : 'N');
    cout << endl;
}

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

	go();

	return 0;
}