시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 1 1 1 100.000%

문제

BINUS University has N rooms to be used as lecture classes. These N rooms are numbered from 1 to N and arranged in a straight line, where the 1st room is the left-most room, and the Nth room is the right-most room.

On one fine afternoon, Ayu and Budi, two BINUS’ alumni, visit their lovely alma mater and walk around the campus. At that particular time, there might be a lecture in each class where Ai students attend the lecture in the ith room.

Ayu starts her walk from the xth room and walk in one direction to the first or last room (depends on the direction). While she walks, she counts the total number of students in all the rooms she passed. For example, if she starts from the 5th room and going left, then she will count the total number of students in the 5th, 4th, 3rd, 2nd, and 1st room. If she is going right, then she will count the total number of students from the 5th room up to the Nth room. Budi also does a similar thing as Ayu, however, instead of counting the total number of students, Budi only counts the number of rooms which are not being used (empty rooms) at that time, i.e. when Ai = 0.

Given array A (representing the number of students in each room), Ayu’s starting point (x1), Ayu’s direction, Budi’s starting point (x2), and Budi’s direction, compute the total number of students in Ayu’s walk and the total number of empty rooms in Budi’s walk.

입력

Input begins with an integer N (1 ≤ N ≤ 100) representing the number of rooms. The second line contains N integers: Ai (0 ≤ Ai ≤ 60) representing the number of students in the ith room. If Ai = 0, then it means the room is not being used (empty). The third line contains an integer x1 (1 ≤ x1 ≤ N) and a string d1, representing Ayu’s walk from the x1th room in d1’s direction. The fourth line contains an integer x2 (1 ≤ x2 ≤ N) and a string d2, representing Budi’s walk from the x2th room in d2’s direction. It is guaranteed that d1 and d2 will be either “left” or “right” (without quotes).

출력

Output in a line two integers (separated by a single space) representing the total number of students in Ayu’s walk and the total number of empty rooms in Budi’s walk, respectively.

예제 입력 1

7
10 0 43 21 0 15 0
4 right
5 left

예제 출력 1

36 2

Ayu starts from the 4th room and going right, so she will pass the 4th, 5th, 6th, and 7th room. The number of students in each of these rooms are 21, 0, 15, 0, with a total of 21 + 0 + 15 + 0 = 36.

Budi starts from the 5th room and going left, so he will pass the 5th, 4th, 3rd, 2nd, and 1st room. The rooms which are empty among these are the 5th and 2nd room (2 rooms).

예제 입력 2

5
60 0 20 60 60
1 left
1 right

예제 출력 2

60 1

예제 입력 3

10
0 0 0 45 15 0 20 60 30 0
3 left
6 left

예제 출력 3

0 4