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 <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;



int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n,k;
    long long suma=0;
    vector <int> tab;
    vector <int> tabc;
    long long pref[500007];
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>k;
        tab.push_back(k);
        tabc.push_back(k);
    }
    sort(tab.begin(),tab.end());
    for (int i=0;i<n;i++){
        suma+=tab[i];
        pref[i]=suma;
    }
    int min_krol=tab[tab.size()-1];
    if (tab[0]==tab[tab.size()-1]){
        min_krol=1000000009;    
    }

    for(int i=n-2;i>0;i--){
        if (pref[i]>tab[i+1] and tab[i]>tab[0]){
            min_krol=tab[i];
        }
        else{
            break;
        }
    }
    // cout<<min_krol;
    string wyn;
    for (auto e:tabc){
        if (e>=min_krol){
            wyn+='T';
        }
        else{
            wyn+='N';
        }
    }
    cout<<wyn;




    return 0;
}