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
// Mikołaj Gazeel
// I Liceum im. Bartłomieja Nowodworskiego w Krakowie


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef char i8;
typedef unsigned char u8;
typedef short i16;
typedef unsigned short u16;
typedef int i32;
typedef unsigned int u32;
typedef long long i64;
typedef unsigned long long u64;
typedef float f32; // Dont use plox
typedef double f64;
 
#define arr array
#define vt vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define pqueue priority_queue

#define pb push_back
#define eb emplace_back

using namespace std; 
 
#define st first
#define nd second

#define not_divine_intellect  std::ios_base::sync_with_stdio(false); cin.tie(0)
#define satori i32 __val; cin >> __val; while(__val--)
#define rep(__val) for(i32 __temp = 0; __temp < __val; __temp++)

namespace std {
  template<typename T, typename U>
  ostream& operator<<(ostream &stream, const pair<T,U> &rhs) {
    return stream << rhs.st << ' ' << rhs.nd;
  }
}

#define mt make_tuple
#define mp make_pair

#define all(__arr) __arr.begin(), __arr.end()

constexpr i64 bandit = 14206902137;

bool doable(vt<i32> &fish, i64 size, i32 skip) {
  for(i32 i = 0; i < fish.size(); i++) {
    if(size > fish[i] and (i != skip))
      size += fish[i];
    else if(skip == i)
      continue;
    else
      return false;
  }
  
  return true;
}

i32 main() {
  not_divine_intellect;
  i32 n;
  cin >> n;

  vt<i32> orig(n);

  for(auto &x : orig)
    cin >> x;
  
  vt<i32> catfish = orig;

  sort(all(catfish));
  
  i32 a = 0, b = n;

  while(b > a) {
    i32 mid = (b-a)/2 + a;

    if(doable(catfish, catfish[mid], mid)) {
      //cerr << catfish[mid] << " is doable\n";
      b = mid;
    }
    else {
      //cerr << catfish[mid] << " is not doable\n";
      a = mid + 1;
    }
  }

  catfish.pb(INT_MAX);

  for(i32 i = 0; i < n; i++) {
    if(orig[i] >= catfish[a])
      cout << 'T';
    else
      cout << 'N';
  }

  cout << '\n';
  
}