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
#include<bits/stdc++.h>
#define int long long
#define ll long long

#define BE(x) x.begin(),x.end()
#define EB(x) x.end(),x.begin()

#define st first
#define nd second

using namespace std;


int32_t main(){

	ios::sync_with_stdio(false); cin.tie(NULL);
		
	int n;cin>>n;
	vector<pair<int,int>>V(n);
	vector<int> P(n);
	
	for(int i=0;i<n;i++){
		int k;cin>>k; 
		V[i]={k,i};
	}
	sort(BE(V));
	P[0]=V[0].st;
	for(int i=1;i<n;i++) P[i]=P[i-1]+V[i].st;
	
//	for(auto x:V)cout<<x.st<<" ";cout<<endl;
//	for(auto x:P)cout<<x<<" ";cout<<endl;
	vector<bool>B(n,true), B2(n);
    for(int i=0;i<n-1;i++) B[i]=(P[i]>V[i+1].st);
	{int i=1; while(V[i-1].st==V[i].st) B[i++]=false;}
	{int i=n-1; while(B[i]) i--; while(i>0) B[i--]=false;} 
	for(int i=0;i<n;i++) B2[V[i].nd]=B[i];
//	for(auto x:B)cout<<x<<" ";cout<<endl;
	for(int i=0;i<n;i++) cout<< (B2[i]? "T":"N");

}