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
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>


using namespace std;

void printf(vector< int> arr) {
	for (int i = 0; i < arr.size(); i++) {
		cout << arr[i] <<  " ";
	}
	cout << endl;
	return;
}

bool king_of_ocean(vector<int> arr, int start) {

	long long int sum = arr[start];
	for (int i = 0; i < start; i++) 
		if (arr[i] == sum) return false;
		else sum += arr[i];
	

	for (int j = start + 1; j < arr.size(); j++) 
		if (sum <= arr[j]) return false;
		else sum += arr[j];
	
	
	return true;
}

int binary_search(vector<int>arr) {
	int p = 0;
	int q = arr.size();
	while (p < q) {
		int mid = p + (q - p) / 2;
		if (!king_of_ocean(arr, mid)) p = mid + 1;
		else q = mid;
	} 
	return p;
}

bool check(int a, int b) {
	return a > b;
}

string  solve() {
	int n;
	cin >> n;
	vector<int> arr(n);
	vector<int>original_arr(n);
	for (int i = 0; i < n; i++)cin >> arr[i];
	for (int i = 0; i < n; i++)original_arr[i] = arr[i];

	sort(arr.begin(), arr.end());

	int min_val = arr[binary_search(arr)];
	
	string ans;
	for (int i = 0; i < n; i++) 
		if (min_val > original_arr[i])	ans += 'N';
		else ans += 'T';
	
	return  ans;
}


int main() {
	cout << solve() << endl;
	return 0;
}