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
#include <bits/stdc++.h>
#include<algorithm>
#include <math.h> 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll maxn = 2e5 + 100;
const ll inf = 1e9;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pii pair<ll, pair<int, int>>
#define mp make_pair
#define f first
#define s second
#define all(x) (x).begin(), (x).end()


int main() {
  int n;
  cin >> n;
  vector<pi> w;
  ll tot = 0;
  for(int i = 0; i < n; i++) {
    ll x;
    cin >> x;
    w.pb(mp(x, i));
    tot += x;
  }
  sort(all(w));
  vector<char> ans(n);
  int biggest = w.back().f;
  int i = n-1;
  while (i >= 0) {
    ll prev = w[i].f;
    int cnt = 1;
    int j = i - 1;
    while(j >= 0) {
      if (prev == w[j].f) {
        cnt += 1;
        j -= 1;
      } else {
        break;
      }
    }
    tot -= (prev * cnt);
    if (prev + tot > biggest) {
      for (int x = i; x > i - cnt; x--) {
        ans[w[x].s] = 'T';
      }
    } else {
      break;
    }
    i = j;
  }
  while (i >= 0) {
    ans[w[i].s] = 'N';
    i -= 1;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i];
  }
}