Tour de BINUS

Interview

Time limit1sMemory limit512 MB

Summary
Sum students over Ayu's left or right walk from x1 and count zero-valued rooms over Budi's walk from x2.
Level

Easy2 of 10

Topics
Array, Prefix sum, Implementation
Solved
No attempts yet

Problem

BINUS University has N rooms used as lecture halls. The N rooms are numbered from 1 to N and arranged in a straight line, with room 1 leftmost and room N rightmost.

On one afternoon, Ayu and Budi, two BINUS alumni, visit their alma mater and walk around the campus. At that moment a lecture may be in progress in each room, with Ai students attending the lecture in room i.

Ayu starts her walk from room x and walks in one direction to the first or last room. Along the way, she counts the total number of students in every room she passes. For example, if she starts from room 5 and goes left, she counts the students in rooms 5, 4, 3, 2, and 1. If she goes right, she counts the students from room 5 up to room N. Budi does something similar, but instead of counting students, he counts only the rooms that are not in use (empty rooms) at that moment, that is, rooms where Ai = 0.

Given array A (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

The first line contains an integer N (1 ≤ N ≤ 100), the number of rooms. The second line contains N integers Ai (0 ≤ Ai ≤ 60), the number of students in room i. If Ai = 0, the room is not in use (empty). The third line contains an integer x1 (1 ≤ x1 ≤ N) and a string d1, meaning Ayu walks from room x1 in direction d1. The fourth line contains an integer x2 (1 ≤ x2 ≤ N) and a string d2, meaning Budi walks from room x2 in direction d2. It is guaranteed that d1 and d2 are either "left" or "right".

Output

Output a single line with two integers separated by a single space: the total number of students in Ayu's walk, then the total number of empty rooms in Budi's walk.

Examples3

  1. Example 1

    Input
    7
    10 0 43 21 0 15 0
    4 right
    5 left
    
    Expected output
    36 2
    
  2. Example 2

    Input
    5
    60 0 20 60 60
    1 left
    1 right
    
    Expected output
    60 1
    
  3. Example 3

    Input
    10
    0 0 0 45 15 0 20 60 30 0
    3 left
    6 left
    
    Expected output
    0 4