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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SZ(a) ((int)(a).size())
#define ALL(a) (a).begin(), (a).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

constexpr int kInf = 1000 * 1000 * 1000 + 7;
constexpr int kMod = 1000 * 1000 * 1000 + 7;
constexpr long long kInfLL = 1e18;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vi a(n);
  REP(i, n) cin >> a[i];

  vi b = a;
  sort(ALL(b));
  int l = -1, r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    long long sum = b[m];
    bool failed = false;
    REP(i, n) if (i != m) {
      if (sum <= b[i]) {
        failed = true;
        break;
      }
      sum += b[i];
    }
    if (!failed) r = m; else l = m;
  }
  b.push_back(kInf);

  string rs;
  REP(i, n) {
    rs += a[i] >= b[r] ? 'T' : 'N';
  }

  cout << rs << endl;
}