SPPPSPSS.

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

SPPPSPSS. stands for Sort Permutation Performing Prefix Sort Plus Suffix Sort.

You are given a permutation pp of length nn. You want to sort it in increasing order using the minimum number of operations. In the kk-th operation you need to choose either the prefix of length kk or the suffix of length kk, and sort it in increasing order.

입력

The first line contains one integer nn (1n1061 \le n \le 10^6) --- the size of the permutation.

The second line contains the permutation p_1,p_2,,p_np\_1, p\_2, \ldots, p\_n.

출력

Suppose the minimum number of operations needed to sort the given permutation is equal to mm. Then you should print a string of length m+1m+1, the last character should be ".", and all other characters should be either "P" or "S" describing whether you want to sort prefix ("P") or suffix ("S") in the respective operation.

힌트

This is how the permutation will change in the fourth sample:

BeforeOperationAfter
2 9 5 7 10 6 3 1 8 4S : Sort suffix of length 12 9 5 7 10 6 3 1 8 4
2 9 5 7 10 6 3 1 8 4P : Sort prefix of length 22 9 5 7 10 6 3 1 8 4
2 9 5 7 10 6 3 1 8 4P : Sort prefix of length 32 5 9 7 10 6 3 1 8 4
2 5 9 7 10 6 3 1 8 4P : Sort prefix of length 42 5 7 9 10 6 3 1 8 4
2 5 7 9 10 6 3 1 8 4S : Sort suffix of length 52 5 7 9 10 1 3 4 6 8
2 5 7 9 10 1 3 4 6 8P : Sort prefix of length 61 2 5 7 9 10 3 4 6 8
1 2 5 7 9 10 3 4 6 8S : Sort suffix of length 71 2 5 3 4 6 7 8 9 10
1 2 5 3 4 6 7 8 9 10S : Sort suffix of length 81 2 3 4 5 6 7 8 9 10