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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define mp make_pair
#define pll pair<ll,ll>
#define all(V) V.begin(), V.end()
#define pb push_back
#define sz(x) x.size()
#define st first
#define nd second
#define BOOST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
constexpr ll mod = 1e9+7;
constexpr ll inf = 1e18+10;

bool sort2(const pll& A, const pll& B)
{
    return A.nd<B.nd;
}

int main()
{
    BOOST
    ll n;
    cin>>n;
    vector<pll> V(n);
    ll s = 0;

    for(ll i = 0; i<n; i++)
    {
        cin>>V[i].st;
        V[i].nd = i+1;
        s+=V[i].st;
    }
    sort(all(V));
    ll i = sz(V)-2;
    s -= V[i+1].st;
    while(s>V[i+1].st)
    {
        i--;
        s -= V[i+1].st;
    }
    ll wart = V[i].st;
    sort(all(V),sort2);
    for(ll i = 0 ;i<sz(V); i++)
        cout<< (V[i].st>wart ? "T" : "N");
}