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
116
117
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>


using namespace std;

int main ()

{ 
  ios_base::sync_with_stdio(0);

  int ileR, waga, max, min, suma, nr, juz, tawaga, pocz;
  vector <pair <int,int>> wagi;
  vector <pair <int,int>> wzor;
  vector <string> krol;
  
  max=0;
  min=0;
  juz=0;
  tawaga=0;
  pocz=0;
  
  cin >> ileR;
  
  for (int n=1; n<=ileR; n++)
	krol.push_back("N");
  
  for (int n=1; n<=ileR; n++)
  {
	cin >> waga;
    wagi.push_back(make_pair(waga,n-1));
	wzor.push_back(make_pair(waga,n-1));
  }

  sort (wagi.begin(), wagi.end());
  sort (wzor.begin(), wzor.end());
  
  min=wagi[0].first;
  max=wagi[ileR-1].first;

//  cout << min << " " << max << endl;;
//  for (int n=0; n<ileR; n++)
//  {
//	cout << wagi[n].first << " " << wagi[n].second << " " << krol[n] << endl;
//  }
  
  if ((ileR == 2) and (wagi[1].first > wagi[0].first))
    krol[wagi[1].second]="T";	  
  else
  {
    suma=wagi[0].first;
	
	if (wagi[0].first != wagi[1].first)
	{
      suma=suma+wagi[1].first;
      wagi[1].first=suma;
	  if ((suma >= max) and (juz == 0))
	  {
		nr = 0;
		juz = 1;
	  }
    }
    else
      pocz=1;		
	
	for (int n=2; n<ileR; n++)
//	for (int n=1; n<ileR; n++)
    {
//cout << n << " " << wagi[n].first << endl;
      suma=suma+wagi[n].first;
      wagi[n].first=suma;
	  if ((suma >= max) and (juz == 0))
	  {
		nr = n - 1;
		juz = 1;
	  }
	}	
	
//  cout << nr << endl;	
//  for (int n=0; n<ileR; n++)
//  {
//	cout << wagi[n].first << " " << wagi[n].second << " " << krol[n] << " " << wzor[n].first <<endl;
//  }  

    for (int n=0; n<ileR; n++)
    {
//	  cout << wagi[n].first << " " << wagi[n].second << " " << krol[n] << endl;
      if (min != max)
	    if (wagi[n].first >= max)
	      krol[wagi[n].second]="T";
    }
    if (wagi[nr].first + wzor[nr].first >= max)
      tawaga=wzor[nr].first;

//for (int n=0; n<ileR; n++)
//  cout << krol[n];
//cout << tawaga << endl;;

      if ((wzor[nr-1].first == tawaga) and (pocz ==0))
	    while (wzor[nr].first == tawaga)
	    {
	      krol[wagi[nr].second]="T";
		  nr=nr-1;
	    }

  }
  
  for (int n=0; n<ileR; n++)
	cout << krol[n];

return 0;
}