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
#include <bits/stdc++.h>
using namespace std;

#define int long long


bool check(const vector<int>& v, int val)
{
    bool skipped = false;
    int new_size = val;
    for(int x : v)
    {
        if(x == val && !skipped)
        {
            skipped = true;
            continue;
        }
        if(x < new_size)
        {
            new_size += x;
        }
    }
    if(new_size > v.back())
        return true;
    return false;
}

int solve(const vector<int>& v)
{
    int beg = 0; int end = v.size();
    while(beg + 1 != end)
    {
        int mid = (beg+end)/2;
        if(check(v, v[mid]))
            end = mid;
        else
            beg = mid;
    }
    if(end == v.size())
    return v.back() + 1;
    return v[end];
}

main()
{
ios_base::sync_with_stdio(false);

int n; cin >> n;
vector<int> v, input;
for(int i=0; i<n; i++)
{
    int a; cin >> a; v.push_back(a);
}
input = v;
sort(v.begin(), v.end());

int M = solve(v);
for(int x : input)
{
    if(x < M)
        cout << "N";
    else
        cout << "T";
}
cout << endl;

return 0;
}