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
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <bits/stdc++.h>

using namespace std;


vector<long long > sum;
vector<long long > sums;
vector<long long > pref;

bool h(long long  siz)
{  
    bool byl=0;
    int sizs = siz;
    for (int i=0;i<sums.size();++i)
    {
        if (sums[i] == sizs and !byl)
        {
            byl=true;
            continue;
        }

        if (sums[i] < siz)
        {
            siz+=sums[i];
        }
        else
        return false;
    }    
    return true;
}

int  main()
{
    long long  n;
    cin >> n;
    for (long long  i=0;i<n;++i)
    {
        long long  pom;
        cin >> pom;
        sum.push_back(pom);
        sums.push_back(pom);
        
    }
    
    sort(sums.begin(), sums.end());

    for (long long  i=0;i<n;++i)
    {
        long long  pom = sums[i];
        pref.push_back( (i==0 ? 0 : pref[i-1]) + pom );
    }



    long long  a=0;
    long long  b=sums.size()-1;
    long long  lim =0;

    while(b-a != 1)
    {
        if (h(sums[(a+b)/2]) )
        {
            b=(a+b)/2;
        }
        else
        {
            a=(a+b)/2;
        }
    }
    lim = sums[(a+b)/2];

    for (long long  i=0;i<n;++i)
    {
        cout << (  sum[i] > lim ? "T" : "N");
    }
    cout << endl;

}

/*

6
2 7 1 8 2 8

4
2 2 2 3

3
5 4 4

6
20 4 5 5 5 5
6
1 1 1 1 1 2137
4
1 1 5 2137

5
2 2 3 6 12

1000000000
999999999


8
1 2 2 3 3 3 3 13


8
8 1 6 4 2 7 5 2


8
5 1 5 6 3 7 6 7
*/