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
#include <bits/stdc++.h>
using namespace std;
typedef intmax_t I;
constexpr I inf = 1e18;
typedef pair<I, I> II;
typedef double F;

#define debug_printable(template_thingies, type, start, printer, stop) \
  template <template_thingies>                                         \
  ostream &operator<<(ostream &o, const type &v) {                     \
    for (auto i = (o << start, v.begin()); i != v.end(); ++i)          \
      (i != v.begin() && (o << ", ")), o << printer;                   \
    return o << stop;                                                  \
  }
#define comma ,
debug_printable(typename T, vector<T>, "[", *i, "]");
debug_printable(typename T comma size_t N, array<T comma N>, "<", *i, ">");
debug_printable(typename T, set<T>, "{", *i, "}");
debug_printable(typename T comma typename U, map<T comma U>, "{",
                i->first << ": " << i->second, "}");
template <typename T, typename U>
ostream &operator<<(ostream &o, pair<T, U> p) {
  return o << "(" << p.first << ", " << p.second << ")";
}

int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  I n;
  cin >> n;
  vector<II> v(n);
  for (I i = 0; i < n; ++i) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v.begin(), v.end());
  // cout << v << endl;
  vector<bool> r(n);
  // todo: n = 1

  vector<I> p(n);
  p[0] = v[0].first;
  for (I i = 1; i < n; ++i) p[i] = p[i - 1] + v[i].first;

  for (I i = 0; i < n;) {
    if (v[0].first == v[i].first) {
      ++i;
      continue;
    }
    I j = i + 1;
    while (j < n && p[j - 1] > v[j].first) ++j;

    // cout << i << ": " << j << endl;

    if (j == n) {
      for (I k = i; k < j; ++k) r[v[k].second] = true;
    }

    i = j;
  }
  if (n == 1) r[0] = true;
  for (I i = 0; i < n; ++i) cout << (r[i] ? 'T' : 'N');
  cout << "\n";
}