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;


bool able(long long s,vector<long long> &vec,long long sum) {

    long long curr = vec[s];
    //bool it_self = false;
    for(int k=0;k<vec.size();k++) {
        if(vec[k] < curr && k != s)
            curr += vec[k];
    }
    //cout << curr << " " << sum <<endl;
    if(curr == sum)
        return true;
    return false;
}

long long bin_ser(long long l,long long r,vector<long long> &vec,long long sum) {

    while(l!=r) {

        long long s = (l+r)/2;
        if(able(s,vec,sum)) {
            r = s;
        }
        else
            l = s+1;
    }
    return l;

}

int main() {

    ios_base::sync_with_stdio(0);
    int z = 1;
    //cin >> z;
    while(z--) {
    int n;
    cin >> n;
    vector<long long> vec(n);
    long long sum = 0;
    long long last = -1;
    bool able = false;
    for(int k=0;k<n;k++) {
        cin >> vec[k];
        sum+=vec[k];
        if(last == -1)
            last = vec[k];
        else if(last !=vec[k])
            able = true;

    }
    vector<long long> sorted = vec;
    sort(sorted.begin(),sorted.end());
    long long mini = bin_ser(0,n-1,sorted,sum);
    //cout << mini <<endl;
    for(auto t:vec) {
        if(t >= sorted[mini] && able)
            cout << "T";
        else
            cout << "N";
    }
    cout <<endl;
    }
}