There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the distance in meters from the center of the collider, x_{i} is the coordinate of the i-th particle and its position in the collider at the same time. All coordinates of particle positions are even integers.

You know the direction of each particle movement — it will move to the right or to the left after the collider's launch start. All particles begin to move simultaneously at the time of the collider's launch start. Each particle will move straight to the left or straight to the right with the constant speed of 1 meter per microsecond. The collider is big enough so particles can not leave it in the foreseeable time.

Write the program which finds the moment of the first collision of any two particles of the collider. In other words, find the number of microseconds before the first moment when any two particles are at the same point.


-----Input-----

The first line contains the positive integer n (1 ≤ n ≤ 200 000) — the number of particles. 

The second line contains n symbols "L" and "R". If the i-th symbol equals "L", then the i-th particle will move to the left, otherwise the i-th symbol equals "R" and the i-th particle will move to the right.

The third line contains the sequence of pairwise distinct even integers x_1, x_2, ..., x_{n} (0 ≤ x_{i} ≤ 10^9) — the coordinates of particles in the order from the left to the right. It is guaranteed that the coordinates of particles are given in the increasing order. 


-----Output-----

In the first line print the only integer — the first moment (in microseconds) when two particles are at the same point and there will be an explosion. 

Print the only integer -1, if the collision of particles doesn't happen. 


-----Examples-----
Input
4
RLRL
2 4 6 10

Output
1

Input
3
LLR
40 50 60

Output
-1



-----Note-----

In the first sample case the first explosion will happen in 1 microsecond because the particles number 1 and 2 will simultaneously be at the same point with the coordinate 3. 

In the second sample case there will be no explosion because there are no particles which will simultaneously be at the same point.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
n = int(input())
s = input()
x = list(map(int, input().split()))
mn = 10000000000
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		if x[i + 1] - x[i] < mn:
			mn = x[i + 1] - x[i]
if mn == 10000000000:
	print(-1)
else:
	print(mn // 2)


N = int(input())
if N == 1:
	print(-1)
	exit()
S = input()
X = list(map(int, input().split()))
stk = []
ans = int(1000000000.0)
for (s, x) in zip(S, X):
	if len(stk) == 0:
		stk.append((s, x))
		continue
	top = stk[-1]
	if top[0] == 'R' and s == 'L':
		ans = min(ans, x - (top[1] + x) // 2)
		stk.pop()
	else:
		stk.append((s, x))
if ans == int(1000000000.0):
	print(-1)
else:
	print(ans)


import sys, math
n = int(input())
s = input()
z = list(map(int, input().split()))
best = 10 ** 9
for i in range(len(s) - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		best = min(best, z[i + 1] - (z[i] + z[i + 1]) // 2)
if best != 10 ** 9:
	print(best)
else:
	print(-1)


import math
n = int(input())
s = input()
lt = list(input().split())
l = len(lt) - 1
mn = 10 ** 10
for i in range(l):
	if s[i] == 'R' and s[i + 1] == 'L':
		a = int(lt[i + 1]) - int(lt[i])
		if a < mn:
			mn = a
if mn == 10 ** 10:
	print(-1)
else:
	print(math.ceil(mn / 2))


n = int(input())
a = input()
b = [int(i) for i in input().split()]
p = []
for i in range(n - 1):
	if a[i:i + 2] == 'RL':
		p.append(b[i + 1] - b[i])
if len(p) != 0:
	print(min(p) // 2)
else:
	print(-1)


n = int(input())
S = input()
l = list(map(int, input().split()))
ma = 10000000000
for i in range(1, n):
	if S[i - 1] == 'R' and S[i] == 'L':
		if ma > abs(l[i] - l[i - 1]) // 2:
			ma = abs(l[i] - l[i - 1]) // 2
if ma == 10000000000:
	print(-1)
else:
	print(ma)


import math
n = int(input())
s = input()
arr = input().split()
l = -1
ind = 0
counter = 0
len_n = len(s)
while counter < len_n:
	ind = s.find('RL', ind)
	counter += 1
	if ind == -1:
		break
	else:
		x = int(arr[ind + 1]) + int(arr[ind])
		tmp = int(arr[ind + 1]) - int(x / 2)
		if l == -1:
			l = tmp
		if tmp < l:
			l = tmp
	ind += 2
print(l)


n = int(input())
s = list(input())
x = input().split()
min = -1
for i in range(n):
	x[i] = int(x[i])
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		m = int((x[i + 1] - x[i]) / 2)
		if min == -1 or m < min:
			min = m
print(min)


n = int(input())
s = input()
l = [int(x) for x in input().split()]
t = float('inf')
for i in range(1, n):
	if s[i - 1] == 'R' and s[i] == 'L':
		x = (l[i] - l[i - 1]) // 2
		t = min(x, t)
if t == float('inf'):
	print(-1)
else:
	print(t)


n = int(input())
string = input()
l = list(map(int, input().split()))
results = []
for i in range(n - 1):
	if string[i] == 'R' and string[i + 1] == 'L':
		results.append(l[i + 1] - l[i])
if len(results) == 0:
	print(-1)
else:
	print(min(results) // 2)


n = int(input())
sr = input()
ans = 10 ** 9
arr = list(map(int, input().split()))
for i in range(n - 1):
	m = arr[i + 1] - arr[i]
	if sr[i + 1] == 'L' and sr[i] == 'R':
		temp = m // 2
		if temp < ans:
			ans = temp
if ans != 10 ** 9:
	print(ans)
else:
	print('-1')


from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
l = list(map(int, stdin.readline().split()))
m = float('inf')
p = 0
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		ans = (l[i + 1] - l[i]) // 2
		m = min(ans, m)
		p = 1
if p == 0:
	print(-1)
else:
	print(m)


n = int(input())
moves = list(input())
pos = [int(x) for x in input().split()]
minTime = 1000000000
for i in range(n - 1):
	if moves[i] == 'R' and moves[i + 1] == 'L':
		time = int((pos[i + 1] - pos[i]) / 2)
		minTime = min(time, minTime)
if minTime != 1000000000:
	print(minTime)
else:
	print(-1)


import time
n = int(input())
N = [i for i in input()]
x = [int(i) for i in input().split()]
start = time.time()
flag = False
ans = float('Inf')
for i in range(n):
	if N[i] == 'R':
		left = i
		flag = True
	elif flag == True:
		buf = x[i] - x[left]
		if buf < ans:
			ans = buf
		flag = False
if ans < float('Inf'):
	print(ans // 2)
else:
	print(-1)
finish = time.time()


n = int(input())
(a, b, c) = (input(), list(map(int, input().split())), [])
for i in range(n - 1):
	if a[i] == 'R' and a[i + 1] == 'L':
		c.append((b[i + 1] - b[i]) // 2)
print(-1 if len(c) == 0 else min(c))


n = int(input())
a = input()
b = list(map(int, input().split()))
r = []
for x in range(len(a) - 1):
	if a[x] == 'R' and a[x + 1] == 'L':
		r.append((b[x + 1] - b[x]) // 2)
if r == []:
	print(-1)
else:
	print(min(r))


def main():
	input()
	(l, r) = ([], [])
	for (c, x) in zip(input(), list(map(int, input().split()))):
		if c == 'L':
			l.append(x)
		else:
			r.append(x)
	(ilo, ihi) = (iter(r), iter(l))
	res = 10 ** 10
	try:
		(lo, hi) = (next(ilo), next(ihi))
		while True:
			if lo < hi:
				if res > hi - lo:
					res = hi - lo
				lo = next(ilo)
			else:
				hi = next(ihi)
	except StopIteration:
		print(res // 2 if res < 10 ** 10 else -1)

def __starting_point():
	main()
__starting_point()


particles = int(input())
arrayOfMovement = list(str(input()))
arrayOfCoordinates = list(map(int, input().split()))
min = 10000000000
flag = 0
for i in range(0, len(arrayOfMovement)):
	if i != len(arrayOfMovement) - 1 and arrayOfMovement[i] == 'R' and (arrayOfMovement[i + 1] == 'L'):
		x = arrayOfCoordinates[i + 1] - arrayOfCoordinates[i]
		x /= 2
		if x < min:
			flag = 1
			min = x
if flag == 1:
	print(int(min))
else:
	print('-1')


n = int(input())
dirs = input().strip()
pos = tuple((int(_) for _ in input().split()))
sentinel = 10 ** 9 + 1
best = sentinel
i = dirs.find('RL')
while i >= 0:
	best = min(best, pos[i + 1] - pos[i])
	i = dirs.find('RL', i + 2)
if best == sentinel:
	print(-1)
else:
	print(best // 2)


n = int(input()) - 1
D = input()
C = tuple(map(int, input().split()))
m = INF = 2147483647
for i in range(n):
	if 'R' == D[i] and 'L' == D[1 + i]:
		m = min(m, C[1 + i] - C[i])
print(m >> 1 if INF > m else -1)


(n, k) = (int(input()), input())
l = list(map(int, input().split()))
h = [(l[i + 1] - l[i]) // 2 for i in range(n - 1) if k[i] == 'R' and k[i + 1] == 'L']
if len(h) == 0:
	print(-1)
else:
	print(min(h))


n = int(input())
t = input()
x = [int(q) for q in input().split()]
r = []
for i in range(n - 1):
	if t[i] == 'R' and t[i + 1] == 'L':
		r.append(abs(x[i + 1] - x[i]) // 2)
if len(r) == 0:
	print(-1)
else:
	print(min(r))


n = int(input())
s = input()
a = [int(x) for x in input().split()]
mind = 1000000001
for i in range(0, n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		d = a[i + 1] - a[i]
		if mind > d:
			mind = d
if mind == 1000000001:
	print(-1)
else:
	print(mind // 2)


n = int(input())
w = input()
p = input().split()
b = []
for i in range(len(w) - 1):
	if w[i] == 'R':
		if w[i + 1] == 'L':
			b.append((int(p[i + 1]) - int(p[i])) // 2)
b.sort()
if len(b) > 0:
	print(b[0])
else:
	print(-1)


n = int(input())
m = input()
p = list(map(int, input().split()))
x = []
if m.find('RL') == -1:
	print(-1)
else:
	for i in range(n):
		if i != n - 1:
			if (m[i] == 'R') & (m[i + 1] == 'L'):
				x.append((p[i + 1] - p[i]) // 2)
			else:
				exit
	print(min(x))


n = int(input())
napr = input()
stroka = input()
coord = []
k = ''
answer = 10 ** 10
for i in range(0, len(stroka)):
	if i == len(stroka) - 1:
		coord.append(int(k + stroka[i]))
	elif stroka[i] == ' ':
		coord.append(int(k))
		k = ''
	else:
		k += stroka[i]
for i in range(1, n):
	if napr[i] == 'L' and napr[i - 1] == 'R' and ((coord[i] - coord[i - 1]) // 2 + (coord[i] - coord[i - 1]) % 2 < answer):
		answer = (coord[i] - coord[i - 1]) // 2 + (coord[i] - coord[i - 1]) % 2
if answer == 10 ** 10:
	answer = -1
print(answer)


x = int(input())
n = input()
m = list(map(int, input().split()))[:x]
ar = []
s = 0
mini = 1000000000000000000
for i in n:
	ar.append(i)
for j in range(0, x - 1):
	if ar[j] == 'R' and ar[j + 1] == 'L':
		s = (m[j + 1] - m[j]) // 2
		mini = min(mini, s)
if s:
	print(mini)
else:
	print('-1')


n = int(input())
configuration = list(input())
x = 0
l1 = [int(num) for num in input().split(' ')]
l2 = []
for i in range(len(configuration) - 1):
	if configuration[i] == 'R' and configuration[i + 1] == 'L':
		l2.append(i)
l3 = []
if len(l2) == 0:
	print(-1)
else:
	for i in l2:
		l3.append(l1[i + 1] - l1[i])
	print(min(l3) // 2)


n = int(input())
dir = input()
pos = list(map(int, input().split(' ')))
c = 1000000000
count = 0
if 'R' not in dir:
	print(-1)
elif 'L' not in dir:
	print(-1)
else:
	for i in range(n - 1):
		if dir[i] == 'R' and dir[i + 1] == 'L':
			x = (pos[i + 1] - pos[i]) // 2
			count += 1
			if x < c:
				c = x
			else:
				pass
		else:
			pass
	if count >= 1:
		print(c)
	else:
		print(-1)


n = int(input())
d = input()
x = list(map(int, input().split()))
ans = -1
for i in range(n - 1):
	if d[i] == 'R' and d[i + 1] == 'L' and (x[i] < x[i + 1]):
		a = (x[i + 1] - x[i]) / 2
		if ans == -1:
			ans = a
		elif a < ans:
			ans = a
	elif d[i] == 'L' and d[i + 1] == 'R' and (x[i] > x[i + 1]):
		a = (x[i] - x[i + 1]) / 2
		if ans == -1:
			ans = a
		if a < ans:
			ans = a
print(int(ans))


n = int(input())
direction = input()
xi = [int(x) for x in input().split(' ')]
m = []
for i in range(n - 1):
	if direction[i:i + 2] != 'RL':
		continue
	m.append(xi[i + 1] - xi[i])
if not m:
	print(-1)
else:
	print(int(min(m) / 2))


n = int(input())
s = input()
a = list(map(int, input().split()))
Min = 2000000000
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		Min = min(Min, a[i + 1] - a[i])
if Min != 2000000000:
	print(int(Min / 2))
else:
	print(-1)


n = int(input())
s = input()
x = list(map(int, input().split()))
ans = 10000000000.0
lal = -1
lar = -1
for i in range(n):
	if s[i] == 'L':
		if lar != -1:
			ans = min(ans, x[i] - x[lar])
		lal = i
	elif s[i] == 'R':
		lar = i
if ans != 10000000000.0:
	print(int(ans / 2))
else:
	print(-1)


n = int(input())
dir = input()
dist = [int(x) for x in input().split()]
sz = len(dir) - 1
time = -1
for i in range(sz):
	if dir[i] == 'R' and dir[i + 1] == 'L':
		x = int((dist[i + 1] - dist[i]) / 2)
		if time == -1 or x < time:
			time = x
print(time)


n = int(input())
s = input()
a = list(map(int, input().split()))
ans = 10000000000000
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		ans = min(ans, (a[i + 1] - a[i]) // 2)
if ans == 10000000000000:
	print(-1)
else:
	print(ans)


import array
import bisect
IMPOSSIBLE = -1
INF = 10 ** 10

def compute_collision_time(dirs, xs):
	ans = INF
	rights = array.array('L')
	lefts = array.array('L')
	for (idx, x) in enumerate(xs):
		if dirs[idx] == 'R':
			rights.append(x)
		else:
			lefts.append(x)
	num_lefts = len(lefts)
	for right in rights:
		idx = bisect.bisect_left(lefts, right)
		if idx < num_lefts:
			ans = min(ans, (lefts[idx] - right) // 2)
	return ans if ans < INF else IMPOSSIBLE

def main():
	_ = input()
	dirs = input()
	xs = map(int, input().split())
	print(compute_collision_time(dirs, xs))
main()


amount = int(input())
direction = input()
coord = [int(i) for i in input().split()]
modulus1 = list()
modulus2 = list()
for i in range(amount - 1):
	modulus1.append(coord[i + 1] - coord[i])
for i in range(amount):
	if direction[i] == 'L':
		coord[i] -= 1
	else:
		coord[i] += 1
for i in range(amount - 1):
	modulus2.append(coord[i + 1] - coord[i])
min = 1000000001
for i in range(amount - 1):
	if modulus1[i] < min:
		if modulus1[i] > modulus2[i]:
			min = modulus1[i]
if min == 1000000001:
	print(-1)
else:
	print(int(min / 2))


from itertools import product
from math import ceil, gcd, sqrt
import string
from decimal import Decimal

def binary_table(string_with_all_characters, length_to_make):
	return [''.join(x) for x in product(string_with_all_characters, repeat=length_to_make)]

def all_possible_substrings(string):
	return [int(string[i:j]) for i in range(len(string)) for j in range(i + 1, len(string) + 1)]

def number_of_substrings(length):
	return int(length * (length + 1) / 2)

def is_prime(num):
	for i in range(2, num):
		if num / i == int(num / i) and num != i:
			return False
	return True
num_of_particles = int(input())
movement_directions = input()
array = list(map(int, input().split()))
num = 0
cond = False
all_ = set()
for i in range(len(movement_directions)):
	x = movement_directions[i:i + 2]
	if x == 'RL':
		xd = array[i:i + 2]
		all_.add(int(abs(xd[0] - xd[1]) / 2))
if all_:
	print(min(all_))
else:
	print(-1)


n = int(input())
s = input()
x = list(map(int, input().split()))
minimum = 10000000000
if s.count('RL') == 0:
	print(-1)
else:
	for i in range(n - 1):
		if s[i] == 'R' and s[i + 1] == 'L' and (x[i + 1] - x[i] < minimum):
			minimum = x[i + 1] - x[i]
	print(minimum // 2)


def solve():
	n = int(input())
	movs = input()
	nums = [int(i) for i in input().split()]
	times = []
	for i in range(len(movs) - 1):
		if movs[i] == 'R' and movs[i + 1] == 'L':
			times.append((nums[i + 1] - nums[i]) // 2)
	if times:
		return min(times)
	return -1
print(solve())


n = int(input())
di = input()
pos = list(map(int, input().split()))
mintime = 100000000000
for i in range(n - 1):
	if di[i] == 'R' and di[i + 1] == 'L':
		time = int((pos[i + 1] - pos[i]) / 2)
		if time < mintime:
			mintime = time
if mintime == 100000000000:
	print(-1)
else:
	print(mintime)


n = int(input())
a = input()
arr = list(map(int, input().split()))
arr2 = []
for i in range(0, n - 1):
	if a[i] == 'R' and a[i + 1] == 'L':
		arr2.append(arr[i + 1] - arr[i])
if arr2 == []:
	print(-1)
else:
	print(min(arr2) // 2)


n = int(input())
s = input()
c = list(map(int, input().split()))
flag = False
flag1 = False
(r, l) = (0, 0)
arr = []
for i in range(n):
	if s[i] == 'R':
		flag = True
		r = c[i]
	elif s[i] == 'L' and flag:
		flag1 = True
		l = c[i]
		arr.append(l - r)
if len(arr) == 0:
	print(-1)
	exit(0)
print(min(arr) // 2)


(c, k, n, a, l) = (-1, [], int(input()), input(), list(map(int, input().split())))
for i in range(n):
	if a[i] == 'R':
		c = i
	elif c >= 0:
		k.append((l[i] - l[c]) // 2)
if len(k) == 0:
	print(-1)
else:
	print(min(k))


n = int(input())
d = input()
c = list(map(int, input().split()))
anw = 10000000000.0
for i in range(n - 1):
	if d[i] == 'R' and d[i + 1] == 'L':
		anw = min(anw, (c[i + 1] - c[i]) // 2)
if anw >= 10000000000.0:
	print(-1)
else:
	print(anw)


input()
(t, dirs, X) = (500000001, input(), list(map(int, input().split())))
for (dir1, dir2, x1, x2) in zip(dirs, dirs[1:], X, X[1:]):
	t = min(t, (x2 - x1) // 2) if dir1 + dir2 == 'RL' else t
print(t if t < 500000001 else -1)


__author__ = 'Alexander'
import sys
n = int(sys.stdin.readline())
direct = sys.stdin.readline()
positions = sys.stdin.readline().split()
if direct.find('RL') == -1:
	sys.stdout.write('-1')
else:
	start = 0
	expl = 1000000000
	pos = direct.find('RL')
	while pos != -1:
		start += pos
		expl = min(int((int(positions[start + 1]) - int(positions[start])) / 2), expl)
		direct = direct[pos + 2:]
		start += 2
		pos = direct.find('RL')
	sys.stdout.write(str(expl))


n = int(input())
s = input()
a = list(map(int, input().split()))
ans = -1
for i in range(n - 1):
	if s[i:i + 2] == 'RL':
		if abs(a[i] - a[i + 1]) // 2 < ans or ans == -1:
			ans = abs(a[i] - a[i + 1]) // 2
print(ans)


k = ['RL', 'LR']
n = int(input())
s = input()
l = list(map(int, input().split()))
minn = 10 ** 10
p = 0
for i in range(n - 1):
	if s[i:i + 2] == 'RL':
		minn = min(minn, (l[i + 1] - l[i]) // 2)
print(-1 if minn == 10 ** 10 else minn)


n = int(input())
s = input()
p = [int(z) for z in input().split()]
if n == 1:
	print(-1)
else:
	mi = float('Inf')
	for i in range(1, n):
		if s[i] == 'L' and s[i - 1] == 'R':
			mi = min(mi, (p[i] - p[i - 1]) // 2)
	if mi == float('Inf'):
		print(-1)
	else:
		print(mi)


n = int(input())
ds = input()
xs = list(map(int, input().split()))
cs = [i for i in range(len(ds) - 1) if ds[i:i + 2] == 'RL']
if len(cs) == 0:
	print(-1)
	exit()
print(min(((xs[c + 1] - xs[c]) // 2 for c in cs)))


n = int(input())
i = input()
x = input().split(' ')
cr = []
for a in range(len(x)):
	x[a] = int(x[a])
a = 0
while a < n - 1:
	if i[a] == 'R':
		if i[a + 1] == 'L':
			cr.append((x[a + 1] - x[a]) // 2)
			a += 2
		else:
			a += 1
	else:
		a += 1
if len(cr) > 0:
	print(min(cr))
else:
	print(-1)


n = int(input())
d = input()
l = list(map(int, input().split()))
m = 0
r = 10 ** 9
for i in range(n - 1):
	if d[i] == 'R' and d[i + 1] == 'L':
		m = (l[i + 1] - l[i]) / 2
		if m < r:
			r = m
if r == 10 ** 9:
	print(-1)
else:
	print(int(r))


n = int(input())
dir = input()
l = list(map(int, input().split()))
min = max(l)
f = 0
for i in range(n - 1):
	if dir[i] == 'R' and dir[i + 1] == 'L':
		f = 1
		a = (l[i + 1] - l[i]) // 2
		if a < min:
			min = a
if f == 0:
	print(-1)
else:
	print(min)


n = int(input())
di = [i for i in input()]
lst = list(map(int, input().split()))
i = 0
res = []
while i < n:
	if di[i] == 'R':
		f = i
		i += 1
		if i == n:
			break
		while di[i] == 'R':
			f = i
			i += 1
			if i == n:
				break
		if i == n:
			break
		res.append((lst[i] - lst[f]) // 2)
	i += 1
if len(res) == 0 or max(res) == 0:
	print(-1)
else:
	print(min(res))


n = int(input())
s = input()
x = list(map(int, input().split()))
ls = []
l = []
lx = []
if 'RL' in s:
	for i in range(1, n):
		if s[i - 1] == 'R' and s[i] == 'L':
			x1 = x[i - 1]
			x2 = x[i]
			ls.append(x2 - x1)
			l.append(x2 + x1)
			lx.append(x2)
	res = lx[ls.index(min(ls))] - l[ls.index(min(ls))] / 2
	print(int(res))
else:
	print(-1)


n = int(input())
moves = input()
arr = list(map(int, input().split()))
result = arr[-1]
for i in range(n):
	if i == n - 1:
		pass
	elif moves[i] == 'R' and moves[i + 1] == 'L':
		res = (arr[i + 1] - arr[i]) // 2
		if res < result:
			result = res
if result == arr[-1]:
	print(-1)
else:
	print(result)


(_, str, list) = (input(), input(), input().split(' '))
ans = 1234567890
for i in range(1, len(str)):
	if str[i] == 'L' and str[i - 1] == 'R':
		ans = min(ans, (int(list[i]) - int(list[i - 1])) / 2)
if ans == 1234567890:
	print(-1)
else:
	print(int(ans))


import sys
input = sys.stdin.readline()
num_elements = int(input)
line2 = sys.stdin.readline()
line3 = sys.stdin.readline()
line3 = line3.split(' ')
distance = []
for i in range(0, len(line2) - 1):
	if line2[i:i + 2] == 'RL':
		distance.append((int(line3[i]) + int(line3[i + 1])) / 2 - int(line3[i]))
if len(distance) == 0:
	print(-1)
else:
	print(int(min(distance)))


n = int(input())
s = list(input())
x = list(map(int, input().split()))
ans = 10 ** 10
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		ans = min(ans, (x[i + 1] - x[i]) // 2)
if ans > 10 ** 9:
	ans = -1
print(ans)


n = int(input())
s = input()
x = input()
ll = x.split(' ')
l = []
for i in ll:
	l.append(int(i))
mn = 1000000000
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		mnn = abs(l[i + 1] - l[i]) // 2
		if mnn < mn:
			mn = mnn
if mn == 1000000000:
	print(-1)
else:
	print(mn)


n = int(input())
str = input()
collider = input().split(' ')
min = -1
for i in range(n - 1):
	y = int(collider[i])
	z = int(collider[i + 1])
	if str[i] == 'R' and str[i + 1] == 'L':
		if min > -1:
			if (z - y) / 2 < min:
				min = (z - y) / 2
		if min == -1:
			min = (z - y) / 2
print(int(min))


n = int(input())
a = [*enumerate(input())]
b = [*map(int, input().split())]
a.sort(key=lambda x: b[x[0]])
k = 0
r = l = -1
while k < n:
	if a[k][1] == 'R':
		l = k
	elif l > -1:
		c = -(b[a[l][0]] - b[a[k][0]]) // 2
		r = [min(r, c), c][r < 0]
	k += 1
print(r)


n = int(input())
s = input()
a = list(map(int, input().split()))
maxl = -1
mini = 100000000000000000000000
for i in range(n):
	if s[i] == 'R':
		maxl = a[i]
	if s[i] == 'L' and maxl != -1:
		mini = min(mini, a[i] - maxl)
if mini == 100000000000000000000000:
	print(-1)
else:
	print(mini // 2)


import math
n = input()
s = input()
l = list(map(int, input().strip().split()))
lx = []
mini = math.inf
active = False
for (char, value) in zip(s, l):
	lx.append((char, value))
for i in range(0, len(lx) - 1):
	(t1, t2) = (lx[i], lx[i + 1])
	if t1[0] == 'R' and t2[0] == 'L':
		active = True
		mini = min(mini, int((t1[1] + t2[1]) / 2) - t1[1])
if active:
	print(mini)
else:
	print(-1)


N = int(input())
a = input()
b = input()
b = b.split()
x = 0 - 1
for i in range(N - 1):
	if a[i] == 'R' and a[i + 1] == 'L':
		s = (int(b[i + 1]) - int(b[i])) // 2
		if x == 0 - 1:
			x = s
		else:
			x = min(x, s)
print(x)


n = int(input())
s = input()
m = list(map(int, input().split()))
ans = []
if 'RL' in s:
	f = s.index('R')
	s = s[f:]
	m = m[f:]
	for i in range(0, len(s) - 1):
		a = s[i] + s[i + 1]
		if a == 'RL':
			ans.append((m[i + 1] - m[i]) // 2)
	print(min(ans))
else:
	print(-1)


n = int(input())
s = input()
l = list(map(int, input().split()))
res = 10 ** 9 + 1
if n < 2:
	print(-1)
	exit(0)
for i in range(n - 1):
	if (s[i] == 'R' and s[i + 1] == 'L') and (l[i + 1] - l[i]) // 2 < res:
		res = (l[i + 1] - l[i]) // 2
if res == 10 ** 9 + 1:
	print(-1)
else:
	print(res)


n = int(input())
dir = input()
l = [int(i) for i in input().split()]
right = []
left = []
for i in range(n):
	if dir[i] == 'R':
		right.append(l[i])
	else:
		left.append(l[i])
if right == [] or left == []:
	print(-1)
else:
	maximum_left = max(left)
	minimum_right = min(right)
	if maximum_left < minimum_right:
		print(-1)
	else:
		mini = 9999999999
		for i in range(len(l) - 1):
			if dir[i] == 'R' and dir[i + 1] == 'L':
				t = (l[i + 1] - l[i]) // 2
				if t < mini:
					mini = t
		print(mini)


input()
ds = str.strip(input())
xs = map(int, str.split(input()))
best = None
last_right = None
for (d, x) in zip(ds, xs):
	if d == 'R':
		last_right = x
	elif last_right is not None:
		t = (x - last_right) // 2
		best = min(best or t, t)
print(best or -1)


from sys import stdin, stdout
import sys
INF = 100000000000.0
import bisect

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
from collections import defaultdict
import math
n = get_int()
s = get_string()
a = get_array()
ans = INF
f = 0
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		f = 1
		ans = min(ans, (a[i + 1] - a[i]) // 2)
if f == 0:
	print(-1)
else:
	print(ans)


n = int(input())
d = list(str(input()))
line = list(map(int, input().split()))
value = 1000000001
for i in range(n - 1):
	if d[i] == 'R' and d[i + 1] == 'L':
		value = min(value, line[i + 1] - line[i])
if value > 1000000000:
	print(-1)
else:
	print(value // 2)


n = int(input())
r = input()
s = [int(i) for i in input().split()]
c = 10 ** 9 + 1
if r.count('RL'):
	for i in range(n - 1):
		if r[i] == 'R' and r[i + 1] == 'L':
			c = min((s[i + 1] - s[i]) // 2, c)
	print(c)
else:
	print(-1)


n = int(input())
t = input()
m = list(map(int, input().split()))
x = float('inf')
if 'RL' not in t:
	print(-1)
	exit()
for i in range(n - 1):
	if t[i] == 'R' and t[i + 1] == 'L':
		x = min((m[i + 1] - m[i]) // 2, x)
print(x)


n = int(input())
dir = list(input())
coord = input().strip().split(' ')
coord = [int(c) for c in coord]
flag = 0
tmin = 10 ** 9
for i in range(n - 1):
	if dir[i] == 'R' and dir[i + 1] == 'L':
		flag = 1
		tmin = min(tmin, (coord[i + 1] - coord[i]) // 2)
if flag:
	print(tmin)
else:
	print(-1)


n = int(input())
particles = input()
dis = list(map(int, input().split()))
num = particles.count('RL')
if num == 0:
	print(-1)
else:
	ans = 10 ** 18
	curr_idx = 0
	while num != 0:
		idx = particles[curr_idx:].index('RL') + curr_idx
		diff = (dis[idx + 1] - dis[idx]) // 2
		ans = min(diff, ans)
		curr_idx = idx + 1
		num -= 1
	print(ans)


import math
n = int(input())
s = input()
l1 = list(map(int, input().split()))
min1 = math.inf
ind = -1
for i in range(len(s) - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		d = l1[i + 1] - l1[i]
		if d < min1:
			min1 = d
			ind = i
if ind != -1:
	print(min1 // 2)
else:
	print(-1)


n = int(input())
direc = input()
coord = [int(x) for x in input().split()]
prev = ''
minsf = 10000000000.0
for (i, d) in enumerate(direc):
	if prev == 'R' and d == 'L':
		minsf = min(minsf, coord[i] - coord[i - 1])
	prev = d
print(-1 if minsf == 10000000000.0 else minsf // 2)


n = int(input())
directions = input().strip()
positions = list(map(int, input().split()))
last_right_going = None
min_t = None
for (position, direction) in zip(positions, directions):
	if direction == 'L':
		if last_right_going is not None:
			time = (position - last_right_going) // 2
			if min_t is None:
				min_t = time
			else:
				min_t = min(time, min_t)
	else:
		last_right_going = position
print(min_t if min_t is not None else -1)


n = int(input())
t = input()
z = float('inf')
list1 = list(map(int, input().split()))
for i in range(1, n):
	if t[i - 1] == 'R' and t[i] == 'L':
		k = (list1[i] - list1[i - 1]) // 2
		z = min(z, k)
if z == float('inf'):
	print(-1)
else:
	print(z)


n = int(input())
st = input()
a = [int(i) for i in input().split()]
for i in range(n - 1):
	if a[i] == a[i + 1]:
		print(0)
		return
ans = 10 ** 9
for i in range(n - 1):
	if st[i] == 'R' and st[i + 1] == 'L':
		ans = min(ans, (a[i + 1] - a[i]) // 2)
if ans != 10 ** 9:
	print(ans)
else:
	print(-1)


n = int(input())
move = input()
pos = list(map(int, input().split(' ')))
min_monent = 1e+20
for i in range(1, n):
	if move[i] == move[i - 1] or (move[i - 1] == 'L' and move[i] == 'R'):
		continue
	else:
		middle = (pos[i] + pos[i - 1]) / 2
		time = max(pos[i], pos[i - 1]) - middle
		min_monent = min(min_monent, time)
if min_monent == 1e+20:
	print(-1)
else:
	print(int(min_monent))


n = int(input())
s = input()
ans = 1234567890
i = 0
last_r = -1
for x in input().split():
	now = int(x)
	if s[i] == 'R':
		last_r = now
	elif last_r != -1:
		ans = min(ans, (now - last_r) // 2)
	i += 1
if ans == 1234567890:
	print('-1')
else:
	print(ans)


n = int(input())
s = input()
a = list(map(int, input().split()))
if 'L' not in s:
	print(-1)
	exit(0)
if 'R' not in s:
	print(-1)
	exit(0)
ans = []
f = 0
for i in range(n):
	if s[i] == 'R':
		right = a[i]
		f = 1
	elif f and s[i] == 'L':
		left = a[i]
		f = 0
		ans.append([right, left])
m = 10 ** 10
if ans:
	for i in ans:
		val = abs(i[0] - i[1])
		if val < m:
			m = val
	print(m // 2)
else:
	print(-1)


n = int(input())
c = list(input())
p = list(map(int, input().split()))
f = ['R', 'L']
ans = []
for i in range(n - 1):
	if [c[i], c[i + 1]] == f:
		ans.append(p[i + 1] - p[i])
if len(ans) == 0:
	print(-1)
else:
	print(min(ans) // 2)


from sys import stdin, stdout
n = int(stdin.readline())
route = stdin.readline().rstrip()
coordinates = list(map(int, stdin.readline().split()))
ans = float('inf')
coordinate = -1
for i in range(n):
	if route[i] == 'R':
		coordinate = coordinates[i]
	elif coordinate != -1 and route[i] == 'L':
		ans = min((coordinates[i] - coordinate) // 2, ans)
if ans == float('inf'):
	stdout.write('-1')
else:
	stdout.write(str(ans))


n = int(input())
a = input()
answer = float('infinity')
A = list(map(int, input().split()))
for i in range(n - 1):
	if a[i] == 'R' and a[i + 1] == 'L':
		answer = min(answer, (A[i + 1] - A[i]) // 2)
if answer != float('infinity'):
	print(answer)
else:
	print(-1)


n = int(input())
s = input()
x = [int(y) for y in input().split()]
t = float('inf')
pos = s.find('RL')
if pos == -1:
	print(-1)
else:
	while pos != -1:
		t = min(t, (x[pos + 1] - x[pos]) / 2)
		pos = s.find('RL', pos + 1)
	print(int(t))


n = int(input())
s = input()
a = list(map(int, input().split()))
f = 0
for i in range(n):
	if f == 0 and i < n - 1 and (s[i] == 'R') and (s[i + 1] == 'L'):
		t = (a[i + 1] - a[i]) // 2
		f = 1
	elif i < n - 1 and s[i] == 'R' and (s[i + 1] == 'L'):
		t = min(t, (a[i + 1] - a[i]) // 2)
if f == 0:
	print(-1)
else:
	print(t)


n = int(input())
s = input()
x = list(map(int, input().split()))
z = float('inf')
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		z = min(z, (x[i + 1] - x[i]) // 2)
print(-1 if z == float('inf') else z)


n = int(input())
t = input()
arr1 = list(map(int, input().split()))
ans = [arr1[i + 1] - arr1[i] for i in range(n - 1) if t[i] == 'R' and t[i + 1] == 'L']
if ans:
	print(min(ans) // 2)
else:
	print('-1')


n = int(input())
s = input()
a = [int(i) for i in input().split()]
dis = [a[i + 1] - a[i] for i in range(n - 1) if s[i] == 'R' and s[i + 1] == 'L']
if dis:
	print(int(min(dis) / 2))
else:
	print(-1)


n = int(input())
st = input()
lst = list(map(int, input().split()))
minn = float('INF')
yes = False
for i in range(n - 1):
	if st[i] == 'R' and st[i + 1] == 'L':
		yes = True
		minn = min(minn, (lst[i + 1] - lst[i]) // 2)
if not yes:
	print(-1)
else:
	print(minn + 1 + 1 - 2)


n = int(input())
s = input()
a = list(map(int, input().split()))
d = []
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		t = a[i + 1] - a[i]
		t = t // 2
		d.append(t)
if d == []:
	print(-1)
else:
	print(min(d))


I = input
R = range
S = sorted
n = int(I())
r = [[], []]
for (s, v) in zip(I(), map(int, I().split())):
	r[s == 'R'] += [v]
m = 10 ** 9
i = 0
j = 0
a = S(r[0])
b = S(r[1])
while i < len(a) and j < len(b):
	if b[j] > a[i]:
		i += 1
	else:
		m = min(m, (a[i] - b[j]) // 2)
		j += 1
print([m, -1][m == 10 ** 9])


N = int(input())
s = input()
x = [int(y) for y in input().split(' ')]
least_time = -1
for i in range(N - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		time = (x[i + 1] - x[i]) // 2
		if least_time == -1:
			least_time = time
		else:
			least_time = min(least_time, time)
print(least_time)


n = int(input())
t = input()
s = list(map(int, input().split()))
if n == 1:
	print(-1)
else:
	p = []
	for k in range(n - 1):
		if t[k] == 'R':
			if t[k + 1] == 'L':
				p.append((s[k + 1] - s[k]) // 2)
	if len(p) == 0:
		print(-1)
	else:
		print(min(p))


from sys import stdin
inf = 1000 * 1000 * 1000
n = int(input())
directions = stdin.readline()
depart = list(map(int, stdin.readline().split()))
tempsMin = inf
for i in range(n - 1):
	direction = directions[i]
	directionApres = directions[i + 1]
	temps = (depart[i + 1] - depart[i]) // 2
	if direction == 'R' and directionApres == 'L':
		tempsMin = min(temps, tempsMin)
if tempsMin == inf:
	print(-1)
else:
	print(tempsMin)


(n, ans) = (int(input()), 10000000000000.0)
sat = [i for i in input()]
mat = list(map(int, input().split()))
for i in range(n - 1):
	if sat[i] == 'R' and sat[i + 1] == 'L':
		ans = min(ans, (mat[i + 1] - mat[i] + 1) // 2)
print('-1' if ans == 10000000000000.0 else ans)


n = int(input())
s = input()
idxs = list(map(int, input().split()))
r_flag = -1
l_flag = -1
ans = 10 ** 20
for (idx, q) in enumerate(s):
	if q == 'R':
		r_flag = idxs[idx]
	else:
		l_flag = idxs[idx]
		if r_flag != -1:
			ans = min(ans, (l_flag - r_flag) // 2)
print(ans if ans != 10 ** 20 else -1)


n = int(input())
symbol = input()
pos = list(map(int, input().rsplit()))
min = 2 * 10 ** 9
cn = 0
for i in range(0, n - 1):
	if symbol[i] == 'R' and symbol[i + 1] == 'L':
		_ = abs(pos[i] - pos[i + 1])
		cn += 1
		if _ < min:
			min = _
if cn == 0:
	print(-1)
else:
	print(int(min / 2))


from math import inf

def solve():
	n = int(input())
	movs = input()
	nums = [int(i) for i in input().split()]
	min_time = inf
	for i in range(len(movs) - 1):
		if movs[i] == 'R' and movs[i + 1] == 'L':
			current_time = (nums[i + 1] - nums[i]) // 2
			if current_time < min_time:
				min_time = current_time
	if min_time < inf:
		return min_time
	return -1
print(solve())


n = int(input())
dirs = input()
vals = list(map(int, input().split()))
found = False
min = None
for i in range(n - 1):
	ri = dirs[i]
	le = dirs[i + 1]
	if ri + le == 'RL':
		if (vals[i + 1] - vals[i]) % 2 == 0:
			found = True
			if min == None:
				min = vals[i + 1] - vals[i]
			elif min > vals[i + 1] - vals[i]:
				min = vals[i + 1] - vals[i]
if found == True:
	print(int(min / 2))
else:
	print(-1)


def main():
	num = int(input())
	directions = input()
	locations = list(map(int, input().split()))
	min_time = None
	for i in range(num - 1):
		if directions[i] == 'R' and directions[i + 1] == 'L':
			time = (locations[i + 1] - locations[i]) // 2
			if min_time is None or time < min_time:
				min_time = time
	if min_time is None:
		print(-1)
	else:
		print(min_time)
main()


N = int(input())
direct = input()
coord = list(map(int, input().rstrip().split(' ')))
mn = 2000000000.0
for i in range(1, N):
	if direct[i - 1] == 'R' and direct[i] == 'L':
		mn = min(mn, (coord[i] - coord[i - 1] & 1 + coord[i] - coord[i - 1]) // 2)
if mn != 2000000000.0:
	print(mn)
else:
	print(-1)


n = int(input())
dir = input()
nums = list(map(int, input().split()))
diff = ans = c = 0
for i in range(len(dir) - 1):
	if dir[i] == 'R' and dir[i + 1] == 'L':
		diff = nums[i + 1] - nums[i]
	if c == 0 or c > diff / 2:
		c = diff / 2
if c == 0:
	print(-1)
else:
	print(int(c))


n = int(input())
val = input()
crd = list(map(int, input().split()))
cur = -1
ans = 10 ** 19
for i in range(n):
	if val[i] == 'R':
		cur = i
	elif cur != -1:
		ans = min(ans, (crd[i] - crd[cur]) // 2)
if ans < 10 ** 19:
	print(ans)
else:
	print(-1)


import math

def particles():
	total = int(input())
	particles = input()
	particles = [i for i in particles]
	position = list(map(int, input().split()))
	output = math.inf
	change = False
	for i in range(len(particles)):
		if particles[i] == 'R':
			if i + 1 < len(particles):
				if particles[i + 1] == 'L':
					temp = int((position[i + 1] - position[i]) / 2)
					if temp < output:
						output = temp
						change = True
	if not change:
		return -1
	else:
		return output
answer = particles()
print(answer)


n = int(input())
s = input()
a = list(map(int, input().split()))
(l, z) = ([], 0)
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		l.append((a[i + 1] - a[i]) // 2)
		z = -1
if z == 0:
	print(-1)
else:
	print(min(l))


n = int(input())
moves = input()
pos = list(map(int, input().split()))
j = 0
time = []
for i in range(n - 1):
	if moves[i] is 'R' and moves[i + 1] is 'L':
		time.append(int((-pos[i] + pos[i + 1]) / 2))
		j = j + 1
if j is 0:
	time.append(-1)
print(min(time[:]))


def main():
	n = int(input())
	string = str(input())
	a = list(map(int, input().split()))
	mx = a[n - 1] + 100
	for i in range(len(string) - 1):
		if string[i] == 'R' and string[i + 1] == 'L':
			mx = min((a[i + 1] - a[i]) // 2, mx)
	if mx == a[n - 1] + 100:
		print('-1')
	else:
		print(mx)
	return
main()


n = int(input())
s = input()
x = [int(i) for i in input().split()]
minValue = -1
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		r = (x[i + 1] - x[i]) // 2
		if minValue == -1 or r < minValue:
			minValue = r
print(minValue)


class particle:
	x = 0
	o = ''
n = int(input())
st = input()
lt = []
for i in range(len(st)):
	a = particle()
	a.o = st[i]
	lt.append(a)
st = input()
tmp = st.split(' ')
dir = {'R': 1, 'L': -1}
for i in range(len(tmp)):
	lt[i].x = int(tmp[i])
minn = -1
for i in range(len(lt) - 1):
	if dir[lt[i].o] <= dir[lt[i + 1].o]:
		pass
	else:
		t = abs(lt[i].x - lt[i + 1].x) / 2
		if minn < 0 or minn > t:
			minn = t
print(int(minn))


n = int(input())
s = input()
c = [int(x) for x in input().split()]
l = []
f = 0
for i in range(len(s) - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		med = (c[i] + c[i + 1]) / 2
		l.append(abs(med - c[i]))
		f = 1
l = sorted(l)
if f == 1:
	print(int(l[0]))
else:
	print('-1')


def main():
	n = input()
	s = input()
	d = input()
	number = []
	res = False
	maxi = float('inf')
	for i in d.split(' '):
		number.append(int(i))
	for i in range(len(s) - 1):
		if s[i] == 'R' and s[i + 1] == 'L':
			cal = number[i + 1] - number[i]
			if cal < maxi:
				maxi = cal
			res = True
	if res == True:
		maxi = int(maxi / 2)
		print(maxi)
	else:
		print('-1')
main()


import sys
n = int(input())
temp = input()
list1 = [int(x) for x in input().split()]
leftRight = list(temp)
minValue = sys.maxsize
for i in range(len(leftRight) - 1):
	if leftRight[i] == 'R' and leftRight[i + 1] == 'L':
		meter = list1[i] + list1[i + 1]
		meter //= 2
		if meter - list1[i] < minValue:
			minValue = meter - list1[i]
if minValue == sys.maxsize:
	print(-1)
else:
	print(minValue)


n = int(input())
s = input()
arr = list(map(int, input().split()))
mn = float('inf')
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		mn = min(mn, arr[i + 1] - arr[i])
	if mn == 2:
		break
if mn == float('inf'):
	print(-1)
else:
	print(mn // 2)


a = int(input())
direct = input()
l = list(map(int, input().split()))
t = -1
for i in range(a - 1):
	if direct[i] == 'R' and direct[i + 1] == 'L':
		t = min(t, l[i + 1] - l[i]) if t != -1 else l[i + 1] - l[i]
print(t // 2)


NONE = 10 ** 10
n = int(input())
direct = input()
pos = [int(x) for x in input().split()]
best = NONE
for (i, x) in enumerate(pos):
	if i + 1 == n:
		break
	if direct[i:i + 2] != 'RL':
		continue
	best = min(best, pos[i + 1] - x)
if best == NONE:
	best = -1
else:
	best = best // 2
print(best)


import math, sys, re, itertools
(rs, ri, rai) = (input, lambda : int(input()), lambda : list(map(int, input().split())))
n = ri()
s = rs()
xa = rai()
p = None
mini = float('inf')
for (ch, x) in zip(s, xa):
	if p is None:
		if ch == 'R':
			p = (ch, x)
		continue
	if ch == 'R':
		if p[0] == 'R':
			p = (ch, x)
	elif ch == 'L':
		if p[0] == 'R':
			mini = min(mini, (x - p[1]) // 2)
			p = None
if mini == float('inf'):
	print(-1)
else:
	print(mini)


n = int(input())
dir = input()
a = list(map(int, input().split()))
ans = 10 ** 20
for i in range(n - 1):
	if dir[i] == 'R' and dir[i + 1] == 'L':
		ans = min(ans, (a[i + 1] - a[i]) // 2)
if ans == 10 ** 20:
	print(-1)
else:
	print(ans)


import math
n = int(input())
a = input()
b = list(map(int, input().split()))
t = 10 ** 10
flag = 0
for i in range(n - 1):
	if a[i] == 'R' and a[i + 1] == 'L':
		c = (b[i + 1] - b[i]) / 2
		t = min(t, math.ceil(c))
		flag = 1
if flag == 0:
	print(-1)
else:
	print(t)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	s = S()
	a = LI()
	r = inf
	for i in range(n - 1):
		if s[i:i + 2] == 'RL':
			t = (a[i + 1] - a[i]) // 2
			if r > t:
				r = t
	if r == inf:
		return -1
	return r
print(main())


n = int(input())
s = input()
a = list(map(int, input().split()))
ans = float('inf')
test = 0
for i in range(1, n):
	if s[i - 1] == 'R' and s[i] == 'L':
		test = 1
		ans = min(ans, (a[i] - a[i - 1]) // 2)
if test:
	print(ans)
else:
	print(-1)


input()
s = input()
x = [int(i) for i in input().split()]
res = -1
for i in range(len(x) - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		if res == -1 or res > (x[i + 1] - x[i]) // 2:
			res = (x[i + 1] - x[i]) // 2
print(res)


n = int(input())
d = input()
x = list(map(int, input().split()))
result = -1
for i in range(1, n):
	if d[i - 1] != 'R' or d[i] != 'L':
		continue
	if result == -1:
		result = (x[i] - x[i - 1]) // 2
	else:
		result = min(result, (x[i] - x[i - 1]) // 2)
print(result)


n = int(input())
l1 = list(input())
l2 = list(map(int, input().split()))
ans = []
k = 0
for i in range(n - 1):
	if l1[i] == 'R' and l1[i + 1] == 'L':
		k = 1
		break
if k == 0:
	print(-1)
else:
	for i in range(n - 1):
		if l1[i] == 'R' and l1[i + 1] == 'L':
			ans.append((l2[i + 1] - l2[i]) // 2)
	print(min(ans))


flag = False
mini = 1000000000 + 7
n = int(input())
s = input()
l = list(map(int, input().strip().split()))
for i in range(0, n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		flag = True
		mini = min(mini, int((l[i] + l[i + 1]) / 2) - l[i])
if flag == False:
	print(-1)
else:
	print(mini)


n = int(input().strip())
s = input().strip()
a = [int(i) for i in input().strip().split()]
ans = int(1000000000.0)
flag = 1
for i in range(0, n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		flag = 0
		ans = min(ans, (a[i + 1] - a[i]) // 2)
if flag:
	print(-1)
else:
	print(ans)


n = int(input())
s = input()
a = list(map(int, input().split()))
m = 100000000000000
found = 0
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		m = min(m, a[i + 1] - a[i])
		found = 1
print([-1, m // 2][found])


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	n = inp()
	s = input()
	a = inlist()
	res = 1000000000000000
	i = 0
	while i < n:
		if s[i] == 'R':
			for j in range(i + 1, n):
				if s[j] == 'L':
					res = min(a[j] - (a[i] + a[j]) // 2, res)
				else:
					i = j
		i += 1
	if res == 1000000000000000:
		print(-1)
	else:
		print(res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import sys
n = int(input())
s = input()
k = list(map(int, input().split()))
if n == 1:
	print(-1)
	sys.exit()
ans = []
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		f = (k[i + 1] - k[i]) // 2
		ans.append(f)
if ans:
	print(min(ans))
else:
	print(-1)


N = int(input())
Ds = [x for x in input()]
Cs = [int(x) for x in input().split()]
Ans = int(1000000000.0)
for i in range(N - 1):
	if Ds[i] == 'R' and Ds[i + 1] == 'L':
		Ans = min(Ans, (Cs[i + 1] - Cs[i]) // 2)
if Ans == int(1000000000.0):
	print(-1)
else:
	print(Ans)


n = int(input())
d = input()
if 'RL' not in d:
	print(-1)
else:
	l = list(map(int, input().split()))
	r = min(((l[x + 1] - l[x]) // 2 for x in range(n - 1) if d[x:x + 2] == 'RL'))
	print(r)


3
inf = 1000000000.0

def main():
	n = int(input())
	dir = input()
	coords = list(map(int, input().split()))
	res = inf
	maxr = -1
	for i in range(n):
		if dir[i] == 'R':
			maxr = coords[i]
		elif maxr != -1:
			res = min((coords[i] - maxr) / 2, res)
	if res == inf:
		print(-1)
	else:
		print(int(res))
main()


n = int(input())
d = input()
p = list(map(int, input().split()))
m = max(p)
f = 0
for i in range(n - 1):
	if d[i] == 'R' and d[i + 1] == 'L':
		s = (p[i] + p[i + 1]) // 2 - p[i]
		if s < m:
			m = s
		f = 1
if f == 0:
	print(-1)
else:
	print(m)


N = int(input())
S = list(input())
C = list(map(int, input().split()))
an = None
lastR = None
for (i, q) in enumerate(S):
	if q == 'R':
		lastR = C[i]
	elif lastR != None:
		if an == None:
			an = C[i] - lastR
		else:
			an = min(an, C[i] - lastR)
if an != None:
	print(an // 2)
else:
	print(-1)


n = int(input())
x = input()
a = list(map(int, input().split()))
m = []
if 'RL' not in x:
	print(-1)
else:
	for i in range(n - 1):
		if x[i] + x[i + 1] == 'RL':
			m.append((a[i + 1] - a[i]) // 2)
	print(min(m))


n = int(input())
d = list(input())
p = list(map(int, input().split()))
output = -1
for i in range(1, n):
	if d[i - 1] == 'R' and d[i] == 'L':
		if output > 0:
			output = min(output, (p[i] - p[i - 1]) / 2)
		else:
			output = (p[i] - p[i - 1]) / 2
print(int(output))


n = int(input().split()[0])
LR = input()
X = list(map(int, input().split()))
if n == 1:
	print('-1')
	exit()
L = [-1 for i in range(n)]
for (i, lr) in reversed(list(enumerate(LR))):
	if lr == 'L':
		L[i] = X[i]
	else:
		L[i] = L[(i + 1) % n]
mint = float('inf')
for (i, lr) in enumerate(LR):
	if L[i] < 0:
		break
	if lr == 'R':
		t = L[i] - X[i]
		if mint > t:
			mint = t
if mint == float('inf'):
	print('-1')
else:
	print(mint // 2)


from sys import stdin
n = int(input())
str = stdin.readline()
arr = list(map(int, stdin.readline().split()))
r = neg = -1
p = 0
for i in range(n - 1):
	if str[i] == 'R' and str[i + 1] == 'L':
		r = int((arr[i + 1] - arr[i]) / 2)
		if p == 0 or p > r:
			p = r
if r == -1:
	print('-1')
else:
	print(p)


n = int(input())
drctn = list(input())
pos = list(map(int, input().split()))
time = set()
for i in range(n - 1):
	if drctn[i] == 'R' and drctn[i + 1] == 'L':
		time.add((pos[i + 1] - pos[i]) // 2)
if len(time) > 0:
	print(min(time))
else:
	print(-1)


hjCKMBTfcVYmswL = int
hjCKMBTfcVYmswN = input
hjCKMBTfcVYmswO = range
hjCKMBTfcVYmswD = min
hjCKMBTfcVYmswz = print
n = hjCKMBTfcVYmswL(hjCKMBTfcVYmswN())
a = hjCKMBTfcVYmswN()
b = [hjCKMBTfcVYmswL(_) for _ in hjCKMBTfcVYmswN().split()]
x = -1
for i in hjCKMBTfcVYmswO(n - 1):
	if a[i] == 'R' and a[i + 1] == 'L':
		s = (b[i + 1] - b[i]) // 2
		if x == -1:
			x = s
		else:
			x = hjCKMBTfcVYmswD(x, s)
hjCKMBTfcVYmswz(x)


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def loadinput():
	n = int(input())
	di = list(str(input()))
	vals = list(map(int, input().split()))
	return (di, vals)

def checkstews(di, vals):
	ans = -1
	for i in range(len(di) - 1):
		if di[i] == 'R' and di[i + 1] == 'L':
			if vals[i] < vals[i + 1]:
				if int((vals[i + 1] - vals[i]) / 2) < ans or ans == -1:
					ans = int((vals[i + 1] - vals[i]) / 2)
		else:
			continue
	return ans
(di, vals) = loadinput()
ans = checkstews(di, vals)
print(ans)


try:
	while True:
		n = int(input())
		s = input()
		a = list(map(int, input().split()))
		result = -1
		for i in range(1, n):
			if s[i - 1] == 'R' != s[i]:
				t = a[i] - a[i - 1] >> 1
				if result == -1 or t < result:
					result = t
		print(result)
except EOFError:
	pass


n = int(input())
d = input()
l_d = list(map(int, input().split()))
p_R = int(10000000000.0)
p_L = int(10000000000.0)
m_t = int(10000000000.0)
for i in range(n):
	if d[i] == 'R':
		p_R = i
	if d[i] == 'L':
		p_L = i
	if p_R != 10000000000.0 and p_L != 10000000000.0:
		if p_L > p_R:
			m_t = min(m_t, (l_d[p_L] - l_d[p_R]) // 2)
print(-1 if m_t == 10000000000.0 else m_t)


n = int(input())
direction = input()
positions = list(map(int, input().split()))
min_d = positions[-1]
collide = False
for index in range(n - 1):
	if direction[index] == 'R' and direction[index + 1] == 'L':
		collide = True
		min_d = min(min_d, positions[index + 1] - positions[index])
if collide:
	print(int(min_d / 2))
else:
	print(-1)


n = int(input())
moves = input()
loc = [int(x) for x in input().split()]
mins = int(1e+21)
for i in range(1, n):
	if moves[i - 1] == 'R' and moves[i] == 'L':
		mins = min(mins, (loc[i] - loc[i - 1]) // 2)
print([-1, mins][mins != int(1e+21)])


n = int(input())
st = input()
a = list((int(x) for x in input().split()))
collide = False
smallesttime = None
for i in range(0, len(a) - 1):
	if st[i] == 'R' and st[i + 1] == 'L':
		time = (a[i + 1] - a[i]) // 2
		if collide == False:
			collide = True
			smallesttime = time
		elif time < smallesttime:
			smallesttime = time
if not collide:
	print(-1)
else:
	print(smallesttime)


n = int(input())
s = input()
arr = [int(i) for i in input().split()]
li = [arr[i + 1] - arr[i] for i in range(n - 1) if s[i] == 'R' and s[i + 1] == 'L']
if li:
	ans = min(li) // 2
	print(ans)
else:
	print(-1)


n = int(input())
dirs = input()
pos = list(map(int, input().split()))
times = []
for i in range(len(dirs) - 1):
	if dirs[i] == 'R' and dirs[i + 1] == 'L':
		times.append((pos[i + 1] - pos[i]) / 2)
if times:
	print(int(min(times)))
else:
	print(-1)


def main():
	n = int(input())
	d = input()
	o = list(map(int, input().split()))
	res = -1
	for i in range(n - 1):
		if (d[i], d[i + 1]) == ('R', 'L'):
			cur = (o[i + 1] - o[i]) // 2
			if res == -1 or res > cur:
				res = cur
	print(res)
main()


n = int(input())
d = input()
pos = list(map(int, input().split()))
ans = 10 ** 11
for i in range(0, n - 1):
	if d[i] == 'R' and d[i + 1] == 'L':
		ans = min(ans, (pos[i + 1] - pos[i]) // 2)
if ans == 10 ** 11:
	ans = -1
print(ans)


n = int(input())
s = input()
v = [int(i) for i in input().split()]
i = 0
j = 0
f = 0
mt = 1000000001
while i < n:
	while i < n and s[i] != 'R':
		i = i + 1
	while i < n and s[i] == 'R':
		i = i + 1
	i = i - 1
	j = i + 1
	if j >= n:
		break
	while j < n and s[j] != 'L':
		j = j + 1
	if s[j] == 'L':
		f = 1
		t = (v[j] + v[i]) / 2 - v[i]
		if t < mt:
			mt = t
	else:
		break
	if j + 1 < n:
		i = j + 1
	else:
		break
if f == 0:
	print('-1')
else:
	print(int(mt))


n = int(input())
d = input()
a = [int(x) for x in input().split()]
min_t = 10 ** 10
i = 0
while i < n:
	i = d.find('R', i)
	if i == -1:
		break
	while i + 1 < n and d[i + 1] == 'R':
		i += 1
	if i == n:
		break
	j = d.find('L', i + 1)
	if j == -1:
		break
	min_t = min(min_t, a[j] - a[i])
	i = j + 1
if min_t == 10 ** 10:
	print(-1)
else:
	print(min_t // 2)


n = int(input())
s = input().rstrip()
a = list(map(int, input().split()))
(l, r) = ([], [])
for i in range(n):
	if s[i] == 'R':
		r.append(a[i])
	else:
		l.append(a[i])
i = j = 0
ans = 10 ** 10
while i < len(r) and j < len(l):
	if r[i] < l[j]:
		ans = min(ans, l[j] - r[i])
		i += 1
	else:
		j += 1
if ans == 10 ** 10:
	print(-1)
else:
	print(ans // 2)


def arr_inp():
	return [int(x) for x in input().split()]
(n, s) = (int(input()), input())
a = arr_inp()
(m, c1) = (10 ** 9 + 1, 0)
while s.find('RL', c1) != -1:
	ix = s.find('RL', c1)
	m = min(m, (a[ix + 1] - a[ix]) // 2)
	c1 = ix + 2
if c1 == 0:
	exit(print(-1))
print(m)


n = int(input())
s = list(input())
z = list(map(int, input().split()))
a = list()
c = 0
for i in range(n - 1):
	if (s[i] == 'R') & (s[i + 1] == 'L'):
		c += 1
		break
if (c == 0) | (n == 1):
	print('-1')
	exit()
for i in range(n - 1):
	if (s[i] == 'R') & (s[i + 1] == 'L'):
		a.append(z[i + 1] - (z[i] + z[i + 1]) // 2)
print(min(a))
exit()
while 1:
	for i in range(n):
		if s[i] == 'R':
			z[i] += 1
		else:
			z[i] -= 1
		if i == n - 1:
			break
		if s[i + 1] == 'R':
			z[i + 1] += 1
		else:
			z[i + 1] -= 1
		c += 1
		if z[i] == z[i + 1]:
			print(c)
			exit()


import sys

def main(arr):
	curr = None
	m = float('inf')
	for (d, pos) in arr:
		if d == 'L':
			if curr is not None:
				m = min(m, pos - curr)
		elif d == 'R':
			curr = pos
	print(m // 2 if m != float('inf') else -1)
arr = []
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		continue
	if e == 1:
		arr = list((c for c in line.strip()))
	else:
		curr = list(map(int, line.strip().split()))
		arr = list(zip(arr, curr))
main(arr)


n = int(input())
s = input()
arr = [int(x) for x in input().split()]
m = 1000000007
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		m = min((arr[i + 1] - arr[i]) // 2, m)
if m != 1000000007:
	print(m)
else:
	print('-1')


n = int(input())
s = input()
A = input().split()
for i in range(len(A)):
	A[i] = int(A[i])
min1 = 10000000000
for i in range(1, n):
	if A[i] - A[i - 1] < min1 and s[i] == 'L' and (s[i - 1] == 'R'):
		min1 = A[i] - A[i - 1]
if min1 == 10000000000:
	print(-1)
else:
	print(min1 // 2)


n = int(input())
d = input()
x = list(map(int, input().split()))
mi = 2 ** 50
for i in range(1, n):
	if d[i - 1] == 'R' and d[i] == 'L':
		mi = min(mi, (x[i] - x[i - 1]) // 2)
if mi == 2 ** 50:
	print(-1)
else:
	print(mi)


input()
Move = input()
X = list(map(int, input().split()))
Count = 10 ** 10
i = 0
while i < len(X):
	if Move[i] == 'R':
		while i + 1 < len(X) and Move[i + 1] == 'R':
			i += 1
		if 'L' not in Move[i:]:
			break
		Count = min(Count, (X[Move[i:].index('L') + i] - X[i]) // 2)
		if Count == 1:
			print(1)
			exit()
	i += 1
print(-1 if Count == 10 ** 10 else Count)


import sys
input = sys.stdin.readline
print = sys.stdout.write

def main():
	n = int(input())
	st = input().rstrip()
	arr = list(map(int, input().split()))
	answer = 10 ** 18
	for i in range(len(arr) - 1):
		if st[i] == 'R' and st[i + 1] == 'L':
			answer = min(answer, (arr[i + 1] - arr[i] + 1) // 2)
	if answer == 10 ** 18:
		answer = -1
	print(str(answer))
main()


n = int(input())
directions = [x for x in input()]
points = [int(x) for x in input().split()]
m = 9999999999999
flag = False
for x in range(len(directions) - 1):
	if directions[x] == 'R' and directions[x + 1] == 'L':
		a = (points[x] + points[x + 1]) / 2 - points[x]
		flag = True
		if a < m:
			m = a
if flag:
	print(int(m))
else:
	print(-1)


n = int(input())
s = input()
a = list(map(int, input().split()))
(c, d, k) = (0, 0, 0)
mini = 10000000000000000
for i in range(len(s)):
	if s[i] == 'L':
		c += 1
	else:
		d += 1
if c == len(s) or d == len(s):
	k = 1
if 'RL' not in s:
	k = 1
ans = 0
for i in range(len(a) - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		ans = (a[i + 1] - a[i]) // 2
		if ans < mini:
			mini = ans
if k == 0:
	print(mini)
else:
	print('-1')


def main():
	n = int(input())
	s = input()
	(arr, ans) = ([int(i) for i in input().split()], 99999999999999999)
	for i in range(len(s)):
		if s[i] == 'L' and s[i - 1] == 'R' and (i > 0):
			ans = min(ans, abs(arr[i] - arr[i - 1]) // 2)
	print(ans if ans != 99999999999999999 else -1)
main()


n = int(input())
s = input()
x = list(map(int, input().split()))
a = []
if s.count('RL') == 0:
	print(-1)
else:
	for i in range(n - 1):
		if s[i] == 'R' and s[i + 1] == 'L':
			a.append(x[i + 1] - x[i])
	print(min(a) // 2)


n = int(input())
direcoes = input()
posicoes = input().split()
posicoes = [int(x) for x in posicoes]
marcacoes = []
for i in range(0, len(direcoes) - 1):
	if direcoes[i] == 'R' and direcoes[i + 1] == 'L':
		marcacoes.append(i)
if marcacoes == []:
	print(-1)
else:
	tempos = [posicoes[x + 1] - posicoes[x] for x in marcacoes]
	print(int(min(tempos) / 2))


n = int(input())
velocities = input()
coordinates = input()
speed = [0] * n
time = 10 ** 9
coordinates = list(map(int, coordinates.split()))
for i in range(len(velocities) - 1):
	if velocities[i] == 'R' and velocities[i + 1] == 'L':
		time = min(time, (coordinates[i + 1] - coordinates[i]) // 2)
if time == 10 ** 9:
	time = -1
print(time)


n = int(input())
direction = input()
array = list(map(int, input().split()))
count = direction.count('RL')
if count == 0:
	print(-1)
	exit(0)
else:
	first = direction.index('RL')
	dist = array[first + 1] - array[first]
	while count > 1:
		first += direction[first + 1:].index('RL') + 1
		if array[first + 1] - array[first] < dist:
			dist = array[first + 1] - array[first]
		count -= 1
	print(dist // 2)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
N = int(input())
S = input()
A = alele()
Ans = 1e+18
for i in range(N - 1):
	x = S[i] + S[i + 1]
	if x == 'RL':
		a = math.ceil((A[i + 1] - A[i]) / 2)
		Ans = min(Ans, a)
if Ans == 1e+18:
	print(-1)
else:
	print(Ans)


n = int(input())
dir = input()
seq = list(map(int, input().split()))
min = 1000000000
for i in range(1, n):
	if dir[i - 1] == 'R' and dir[i] == 'L':
		if (seq[i] - seq[i - 1]) / 2 < min:
			min = (seq[i] - seq[i - 1]) / 2
if min == 1000000000:
	print('-1')
else:
	print(int(min))


n = int(input().strip())
l = input().strip()
ll = list(map(int, input().split()))
ll1 = []
for i in range(n - 1):
	if l[i] == 'R' and l[i + 1] == 'L':
		ll1.append(abs(ll[i] - ll[i + 1]) // 2)
print(min(ll1) if len(ll1) != 0 else -1)


n = int(input())
s = input()
l = list(map(int, input().split()))
ans = 10 ** 18
last_r = -1
for i in range(len(l)):
	if s[i] == 'R':
		last_r = i
	elif last_r != -1:
		ans = min(ans, (l[i] - l[last_r]) // 2)
if ans == 10 ** 18:
	print(-1)
else:
	print(ans)


n = int(input())
s = input()
x = list(map(int, input().split()))
min = -1
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		cur = (x[i + 1] - x[i]) // 2
		min = cur if cur < min or min == -1 else min
print(min)


hat = int(input())
moves = list(input())
pos = [int(x) for x in input().split()]
ans = []
for i in range(len(moves)):
	if moves[i] == 'R' and i != len(moves) - 1:
		if moves[i + 1] == 'L':
			ans.append(int(abs(pos[i] - pos[i + 1]) / 2))
if len(ans) == 0:
	print(-1)
else:
	print(min(ans))


n = int(input())
k = input()
arr = [int(x) for x in input().split()]
m = 1000000001
for i in range(0, n - 1):
	if k[i] == 'R' and k[i + 1] == 'L':
		m = min(m, (arr[i + 1] - arr[i]) / 2)
if m == 1000000001:
	print(str(-1))
else:
	print(str(int(m)))


import sys
n = int(input())
directions = input().strip()
a = list(map(int, sys.stdin.readline().split()))
ans = []
for i in range(n - 1):
	if directions[i] == 'R' and directions[i + 1] == 'L':
		ans.append((a[i + 1] - a[i]) // 2)
if ans:
	print(min(ans))
else:
	print(-1)


n = int(input())
ds = input()
tl = list(map(int, input().split()))
ans = [tl[i + 1] - tl[i] for i in range(n - 1) if ds[i] == 'R' and ds[i + 1] == 'L']
if len(ans) > 0:
	print(min(ans) // 2)
else:
	print(-1)


n = int(input())
word = input()
numbers = [int(i) for i in input().split()]
distances = []
for pos in range(len(numbers) - 1):
	distances.append(numbers[pos + 1] - numbers[pos])
second_positions = []
for pos in range(len(numbers)):
	if word[pos] == 'L':
		second_positions.append(numbers[pos] - 1)
	else:
		second_positions.append(numbers[pos] + 1)
second_distances = []
for pos in range(len(second_positions) - 1):
	second_distances.append(second_positions[pos + 1] - second_positions[pos])
flag = False
for pos in range(len(distances)):
	if distances[pos] > second_distances[pos]:
		flag = True
if not flag:
	print(-1)
else:
	pos_list = []
	difference_list = []
	for pos in range(len(distances)):
		if distances[pos] > second_distances[pos]:
			pos_list.append(pos)
			difference_list.append(numbers[pos + 1] - numbers[pos])
	position = difference_list.index(min(difference_list))
	final = pos_list[position]
	print(int((numbers[final + 1] - numbers[final]) / 2))


import os
from sys import stdin
numField = int(stdin.readline())
directions = stdin.readline()
length = list(map(int, stdin.readline().split(' ')))
answer = [length[i + 1] - length[i] for i in range(numField - 1) if directions[i] == 'R' and directions[i + 1] == 'L']
if answer:
	print(int(min(answer) / 2))
else:
	print(-1)


n = int(input())
direction = input()
x = list(map(int, input().split()))
ind = direction.find('RL')
if ind == -1:
	print(ind)
	exit()
minimum = (x[ind + 1] - x[ind]) // 2
for i in range(n - 1):
	if direction[i] + direction[i + 1] == 'RL':
		if minimum > (x[i + 1] - x[i]) // 2:
			minimum = (x[i + 1] - x[i]) // 2
print(minimum)


n = int(input())
dirct = input()
cord = list(map(int, input().split()))
ans = [cord[i + 1] - cord[i] for i in range(n - 1) if dirct[i] == 'R' and dirct[i + 1] == 'L']
print(min(ans) // 2) if len(ans) > 0 else print(-1)


n = int(input())
s = input()
x = input().split()
mn = 2000000000
for i in range(len(x)):
	if i > 0 and s[i] == 'L' and (s[i - 1] == 'R'):
		mn = min(mn, (int(x[i]) - int(x[i - 1])) / 2)
if mn == 2000000000:
	print('-1')
else:
	print(int(mn))


n = int(input())
s = input()
x = list(map(int, input().split()))
mi = float('inf')
(L, R) = (float('inf'), float('inf'))
for i in range(n):
	if s[i] == 'R':
		mi = min(mi, abs(x[i] - L) // 2)
		R = x[i]
	else:
		mi = min(mi, abs(x[i] - R) // 2)
if mi == float('inf'):
	print(-1)
else:
	print(mi)


n = int(input())
p = list(input())
nop = list(map(int, input().split()))
ro = []
for x in range(n - 1):
	if p[x] == 'R':
		if p[x + 1] == 'L':
			ro.append(nop[x + 1] - nop[x])
		else:
			pass
	else:
		pass
if ro == list():
	print(-1)
else:
	print(min(ro) // 2)


n = int(input())
s = input()
a = [int(x) for x in input().split()]
if 'RL' not in s:
	print(-1)
	exit(0)
ans = 1000000001
for i in range(0, n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		if (a[i + 1] - a[i]) // 2 < ans:
			ans = (a[i + 1] - a[i]) // 2
print(ans)


n = int(input())
d = input()
x = list(map(int, input().split()))
if 'RL' in d:
	m = 10000000000000000
	for i in range(n - 1):
		if d[i:i + 2] == 'RL':
			m = min(m, x[i + 1] - x[i])
	print(m // 2)
else:
	print(-1)


n = int(input())
directions = list(input())
cordinates = list(map(int, input().split()))
distance = 1000000000000
for i in range(0, n):
	if i < n and i + 1 < n and (directions[i] == 'R') and (directions[i + 1] == 'L'):
		if cordinates[i + 1] - cordinates[i] < distance:
			distance = cordinates[i + 1] - cordinates[i]
if distance == 1000000000000:
	print(-1)
else:
	print(distance // 2)


(n, d, x, v) = (int(input()), input(), list(map(int, input().split())), -1)
for i in range(1, n):
	if d[i - 1] == 'R' and d[i] == 'L':
		c = (x[i] - x[i - 1]) // 2
		if v == -1 or c < v:
			v = c
print(v)


lst = []
z = int(input())
x = list(map(str, input()))
c = list(map(int, input().split()))
for v in range(z - 1):
	if x[v] == 'R':
		if x[v + 1] == 'L':
			b = (c[v + 1] - c[v]) // 2
			lst.append(b)
if len(lst) != 0:
	print(min(lst))
else:
	print(-1)


n = int(input())
direction = str(input())
coord = list(map(int, input().split()))
res = 10 ** 9 + 1
for x in range(len(direction) - 1):
	if direction[x] == 'R' and direction[x + 1] == 'L':
		if coord[x + 1] - coord[x] < res:
			res = coord[x + 1] - coord[x]
if res == 10 ** 9 + 1:
	print('-1')
else:
	print(res // 2)


import collections
s = int(input())
d = input()
x = [int(x) for x in input().split()]
m = max(x) - min(x)
cnt = 0
res = []
if 'RL' not in d:
	print(-1)
else:
	for i in range(len(d) - 1):
		if d[i] == 'R' and d[i + 1] == 'L':
			res.append(int(abs((x[i] - x[i + 1]) / 2)))
	print(min(res))


n = int(input())
s = input()
l = list(map(int, input().split()))
res = float('inf')
ans = False
if n == 1:
	print(-1)
else:
	for i in range(n - 1):
		if s[i] == 'R' and s[i + 1] == 'L':
			ans = True
			res = min(res, abs(l[i] - l[i + 1]) // 2)
	if not ans:
		print(-1)
	else:
		print(res)


n = input()
directions = str(input().strip())
items = list(map(int, input().strip().split()))
l_bound = directions.find('R')
if l_bound != -1:
	min = None
	i = l_bound + 1
	while i < len(directions):
		if directions[i] == 'L':
			if min == None or min > items[i] - items[l_bound]:
				min = items[i] - items[l_bound]
				l_bound = directions.find('R', i)
				if l_bound == -1:
					break
				i = l_bound
				continue
		else:
			l_bound = i
		i += 1
	if min != None:
		print(int(min / 2))
	else:
		print('-1')
else:
	print('-1')


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base=3):
	newnumber = ''
	while number > 0:
		newnumber = str(number % base) + newnumber
		number //= base
	return newnumber
n = ii()
s = input()
a = li()
ans = 10 ** 9
for i in range(n - 1):
	if s[i:i + 2] == 'RL':
		ans = min(ans, (a[i + 1] - a[i]) // 2)
print(-1) if ans == 10 ** 9 else print(ans)


from sys import stdin
import math
T = int(stdin.readline())
numbers = [['L', 0] for i in range(T)]
chars = stdin.readline()
chars = chars.strip()
nums = stdin.readline()
nums = nums.strip()
nums = nums.split()
l = len(chars)
mindist = math.inf
prevR = -1
for i in range(l):
	numbers[i][0] = chars[i]
	numbers[i][1] = int(nums[i])
	if chars[i] == 'R':
		prevR = i
	if chars[i] == 'L':
		if prevR > -1:
			dist = int(nums[i]) - int(nums[prevR])
			if dist < mindist:
				mindist = dist
if mindist == math.inf:
	print(-1)
else:
	print(int(mindist / 2))


h = int(input())
s2 = input()
l1 = list(map(int, input().strip().split()))
res = 999999999999
for i in range(0, len(s2) - 1):
	if s2[i] == 'R' and s2[i + 1] == 'L':
		res = min(res, (l1[i + 1] - l1[i]) // 2)
if res == 999999999999:
	print(-1)
else:
	print(res)


import sys
n = int(input())
string = input()
arr = list(map(int, input().split()))
res = 1000000001
if 'RL' not in string:
	print('-1')
else:
	for i in range(n):
		if i != n - 1 and string[i] == 'R' and (string[i + 1] == 'L'):
			if (arr[i + 1] - arr[i]) // 2 < res:
				res = (arr[i + 1] - arr[i]) // 2
	print(res)


N = int(input())
s = input()
P = list(map(int, input().strip().split(' ')))
start = 0
MIN = 10 ** 10
last = -1
for i in range(N):
	if s[i] == 'R':
		start = 1
		last = P[i]
	elif start == 1:
		temp = P[i]
		temp = (P[i] - last) // 2
		if temp < MIN:
			MIN = temp
		start = 0
	else:
		start = 0
if MIN == 10 ** 10:
	print(-1)
else:
	print(MIN)


n = int(input())
s = input()
pos = [int(i) for i in input().split()]
min = 10 ** 18
nosol = True
for i in range(1, n):
	if s[i - 1] == 'R' and s[i] == 'L':
		dist = pos[i] - pos[i - 1]
		if dist < min:
			min = dist
			nosol = False
if nosol:
	print(-1)
else:
	print(min >> 1)


n = int(input())
m = str(input())
o = [int(i) for i in input().split()]
min = 1000000000
for i in range(0, len(m) - 1):
	if m[i] == 'R' and m[i + 1] == 'L':
		time = (o[i + 1] - o[i]) / 2
		if time < min:
			min = time
if min == 1000000000:
	print(-1)
else:
	print(int(min))


rg = int(input())
user = input()
a = list(map(int, input().split()))
ans = []
flag = False
for i in range(rg - 1):
	if user[i] == 'R' and user[i + 1] == 'L':
		b = a[i + 1] - a[i]
		ans.append(b)
		flag = True
if flag:
	print(int(min(ans) / 2))
else:
	print(-1)


n = int(input())
s = input()
l = [int(x) for x in input().split()]
ans = []
for i in range(len(l) - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		ans.append(l[i + 1] - l[i])
print(min(ans) // 2 if ans else -1)


n = int(input())
Directions = input()
Positions = [int(x) for x in input().split()]
timelist = []
if 'RL' in Directions:
	for i in range(n - 1):
		if Directions[i] == 'R' and Directions[i + 1] == 'L':
			time = (Positions[i + 1] - Positions[i]) / 2
			timelist.append(time)
	print(int(min(timelist)))
else:
	print(-1)


n = int(input())
s = input()
l = list(map(int, input().split()))
answer = 9999999999
for i in range(len(l) - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		answer = min(answer, (l[i + 1] - l[i]) // 2)
if answer == 9999999999:
	print(-1)
else:
	print(answer)


num = int(input())
s = input()
arr = list(map(int, input().split()))
collision = False
ans = float('inf')
for i in range(1, num):
	if s[i - 1] == 'R' and s[i] == 'L':
		ans = min(ans, (arr[i] - arr[i - 1]) // 2)
		collision = True
if not collision:
	print(-1)
else:
	print(ans)


n = input()
n = int(n)
s = input()
num = input()
num = list(num.split(' '))
if n is 1:
	print(-1)
	exit()
ans = 1061109567
for i in range(n - 1):
	if s[i] is 'R' and s[i + 1] is 'L':
		ans = min((int(num[i + 1]) - int(num[i])) // 2, ans)
if ans is 1061109567:
	print(-1)
else:
	print(ans)


n = int(input())
s = input()
m = 10 ** 17
l = list(map(int, input().split()))
for i in range(n - 1):
	if s[i] != s[i + 1]:
		if s[i + 1] != 'R':
			m = min(m, (l[i + 1] - l[i]) // 2)
if m == 10 ** 17:
	m = -1
print(m)


n = int(input())
arr = [[0, ''] for i in range(n)]
a = input()
b = [int(i) for i in input().split()]
for i in range(len(a)):
	arr[i][1] = a[i]
for i in range(len(b)):
	arr[i][0] = b[i]
arr = sorted(arr)
res = 2000000000.0
for i in range(n - 1):
	if arr[i][1] == 'R' and arr[i + 1][1] == 'L':
		res = min(res, (arr[i + 1][0] - arr[i][0]) // 2)
print(-1 if res == 2000000000.0 else res)


n = int(input())
m = input()
moves = [i for i in m]
positions = list(map(int, input().split()))
if not 'RL' in m:
	print(-1)
else:
	mini = positions[-1] - positions[0]
	for i in range(n - 1):
		if moves[i] == 'R' and moves[i + 1] == 'L':
			mini = min(mini, positions[i + 1] - positions[i])
	print(int(mini / 2))


no = int(input())
balls = input()
places = list(map(int, input().split()))
if not ('R' in balls and 'L' in balls) or balls.find('R') == no - 1:
	print(-1)
else:
	tot = []
	start = balls.find('R')
	expl = 0 - places[start]
	need = True
	for i in range(start + 1, no):
		if need == True:
			if balls[i] == 'L':
				expl += places[i]
				expl /= 2
				tot.append(expl)
				need = False
			else:
				expl = 0 - places[i]
		elif balls[i] == 'R':
			expl = 0 - places[i]
			need = True
	if tot == []:
		print(-1)
	else:
		tot.sort()
		print(int(tot[0]))


n = int(input())
s = input()
x = list(map(int, input().split()))
res = 1000000007
for i in range(len(s) - 1):
	a = s[i]
	b = s[i + 1]
	if a == 'R' and b == 'L':
		res = min(res, int((x[i + 1] - x[i]) / 2))
if res >= 1000000007:
	print('-1')
else:
	print(res)


n = int(input())
s = input()
li = list(map(int, input().split()))
res = []
for i in range(n):
	if s[i] == 'R':
		try:
			if s[i + 1] == 'L':
				res.append((li[i + 1] - li[i]) // 2)
		except IndexError:
			continue
print(min(res)) if res else print(-1)


n = int(input())
d = input()
x = list(map(int, input().split()))
inf = 10 ** 10

def solve():
	if n == 1:
		return -1
	ret = inf
	for i in range(1, n):
		if d[i - 1] == 'R' and d[i] == 'L':
			ret = min(ret, (x[i] - x[i - 1]) // 2)
	if ret == inf:
		return -1
	return ret
print(solve())


n = int(input())
movement = list(input())
coord = list(map(int, input().split()))
first_collision = float('inf')
flag = False
for i in range(len(coord) - 1):
	if movement[i] == 'R' and movement[i + 1] == 'L':
		flag = True
		first_collision = min(first_collision, (coord[i + 1] - coord[i]) // 2)
if flag:
	print(first_collision)
else:
	print(-1)


a = int(input())
s = input()
l = list(map(int, input().split()))
ans = []
for i in range(len(s) - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		ans.append((l[i + 1] - l[i]) // 2)
if len(ans) == 0:
	print(-1)
	exit()
print(min(ans))


n = int(input())
a = list(input())
b = list(map(int, input().split()))
k = 0
x = 0
c = []
d = []
e = []
for i in range(len(a) - 1):
	if a[i] == 'R' and a[i + 1] == 'L':
		k = 1
		break
if k == 0:
	print(-1)
else:
	for i in range(len(a) - 1):
		if a[i] == 'R' and a[i + 1] == 'L':
			e.append(b[i])
			e.append(b[i + 1])
			d.append(e)
			e = []
	for i in range(len(d)):
		c.append(d[i][1] - d[i][0])
	x = c[0]
	p = 0
	for i in range(1, len(c)):
		if c[i] < x:
			x = c[i]
			p = i
	print((d[p][1] - d[p][0]) // 2)


N = int(input())
directions = input()
points = [int(x) for x in input().split()]
answer = -1
for i in range(0, N - 1):
	if directions[i] == 'R' and directions[i + 1] == 'L':
		if answer == -1 or answer > (points[i + 1] - points[i]) // 2:
			answer = (points[i + 1] - points[i]) // 2
print(answer)


import sys
import math
import bisect
import itertools
import random
import re

def solve(A, B):
	n = len(A)
	min_val = 10 ** 18
	for i in range(1, n):
		if A[i - 1] == 'R' and A[i] == 'L':
			val = (B[i] - B[i - 1]) // 2
			min_val = min(min_val, val)
	if min_val == 10 ** 18:
		return -1
	return min_val

def main():
	n = int(input())
	A = list(input())
	B = list(map(int, input().split()))
	print(solve(A, B))
main()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
sys.setrecursionlimit(10 ** 5)
n = get_int()
s = get_string()
lst = get_int_list()
flag = False
m = float('inf')
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		flag = True
		m = min(m, (lst[i + 1] - lst[i]) // 2)
if flag:
	print(m)
else:
	print(-1)


n = int(input())
moves = input()
positions = list(map(int, input().split(' ')))
ans = 10 ** 9
for i in range(n - 1):
	if moves[i] == 'R' and moves[i + 1] == 'L':
		ans = min(ans, (positions[i + 1] - positions[i]) // 2)
if ans == 10 ** 9:
	print(-1)
else:
	print(ans)


cases = int(input())
directions = [i for i in input()]
array = [int(i) for i in input().split()]
count = -1
for i in range(1, cases):
	if directions[i] == 'L' and directions[i - 1] == 'R':
		if array[i] - array[i - 1] < count or count == -1:
			count = array[i] - array[i - 1]
if count == -1:
	print(count)
else:
	print(int(count / 2))


x = int(input())
y = list(input())
p = list(map(int, input().split()))
mi = p[x - 1] + 1
for i in range(x - 1):
	if y[i] == 'R' and y[i + 1] == 'L':
		mi = min(mi, p[i + 1] - p[i])
print(mi // 2 if mi != p[x - 1] + 1 else -1)


n = int(input())
r = input()
h = list(map(int, input().split()))
l = []
for i in range(n - 1):
	if r[i] == 'R' and r[i + 1] == 'L':
		l.append(abs(h[i] - h[i + 1]) / 2)
if l == []:
	print(-1)
else:
	print(int(min(l)))


import sys
n = int(input())
directions = input()
coordinates = [int(x) for x in input().split()]
min_time = sys.maxsize * 2 + 1
max_r = -sys.maxsize * 2
for i in range(len(coordinates)):
	if directions[i] == 'L':
		if min_time > (coordinates[i] - max_r) // 2:
			min_time = (coordinates[i] - max_r) // 2
	else:
		max_r = coordinates[i]
if min_time > max(coordinates):
	print(-1)
else:
	print(min_time)


def pro():
	n = int(input())
	s = input()
	a = list(map(int, input().split()))
	cnt = 1000000001
	for i in range(n - 1):
		if s[i] + s[i + 1] == 'RL':
			cnt = min(cnt, (a[i + 1] - a[i]) // 2)
	if cnt == 1000000001:
		print(-1)
	else:
		print(cnt)
pro()


(n, s) = (int(input()), input())
(l, nl) = ([int(ele) for ele in input().split()], [])
for i in range(len(s)):
	try:
		if s[i] == 'R' and s[i + 1] == 'L':
			app = (l[i + 1] - l[i]) / 2
			nl.append(int(app))
	except:
		continue
if len(nl) == 0:
	print(-1)
else:
	print(min(nl))


n = int(input())
d = list(input())
k = []
m = 1000000001
k = [int(i) for i in input().split()]
for i in range(n - 1):
	if d[i] == 'R' and d[i + 1] == 'L':
		if abs((k[i] - k[i + 1]) // 2) < m:
			m = abs((k[i] - k[i + 1]) // 2)
if m == 1000000001:
	print(-1)
else:
	print(m)


n = int(input())
s = input().rstrip()
a = list(map(int, input().rstrip().split()))
maxi = float('inf')
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		maxi = min(maxi, (a[i + 1] - a[i]) // 2)
if maxi == float('inf'):
	print(-1)
else:
	print(maxi)


import sys

def start(s, lst):
	minimum = sys.maxsize
	for i in range(len(lst)):
		if i + 1 < len(lst):
			if s[i + 1] == 'L' and s[i] == 'R':
				if lst[i + 1] - lst[i] < minimum:
					minimum = lst[i + 1] - lst[i]
	if minimum == sys.maxsize:
		return -1
	return minimum // 2
n = int(input())
t = input()
a = [int(j) for j in input().split()]
print(start(t, a))


n = int(input())
particles = input()
positions = map(int, input().split())
temp = None
ans = float('inf')
for (p, x) in zip(particles, positions):
	if temp is None:
		if p == 'R':
			temp = x
	else:
		if p == 'R':
			temp = x
		if p == 'L':
			if abs(temp - x) < ans:
				ans = abs(temp - x)
if ans == float('inf'):
	print(-1)
else:
	print(ans // 2)


n = int(input())
s = str(input())
ip = list(map(int, input().split()))
q = [1 for i in range(n)]
op = []
for i in range(n):
	if s[i] == 'L':
		q[i] = -q[i]
for i in range(n - 1):
	if q[i + 1] - q[i] < 0:
		op.append((ip[i + 1] - ip[i]) / abs(q[i + 1] - q[i]))
if len(op) == 0:
	print(-1)
else:
	print(int(min(op)))


n = int(input())
d = str(input())
p = input().split()
ans = -1
for i in range(1, n):
	if d[i - 1] == 'R' and d[i] == 'L':
		tans = (int(p[i]) - int(p[i - 1])) // 2
		if ans == -1 or tans < ans:
			ans = tans
print(ans)


import sys
n = int(input())
d = input()
x = list(map(int, input().split()))
r = 0
l = 0
m = sys.maxsize
while True:
	r = d.find('R', l)
	if r == -1:
		break
	l = d.find('L', r + 1)
	if l == -1:
		break
	r = l - 1
	if m > (x[l] - x[r]) // 2:
		m = (x[l] - x[r]) // 2
if m == sys.maxsize:
	print(-1)
else:
	print(m)


import math
n = int(input())
s = input()
x = list(map(int, input().split()))
i = 1
v = 10000000009
while i < len(s):
	if s[i - 1] == 'R' and s[i] == 'L' and (math.ceil((x[i] - x[i - 1]) / 2) < v):
		v = math.ceil((x[i] - x[i - 1]) / 2)
	i = i + 1
if v != 10000000009:
	print(v)
else:
	print(-1)


n = int(input())
d = input()
p = input().split(' ')
if 'RL' not in d:
	print(-1)
else:
	l = 0
	c = 1000000000
	while 'RL' in d[l:]:
		l = d[l:].index('RL') + l
		if (int(p[l + 1]) - int(p[l])) / 2 < c:
			c = (int(p[l + 1]) - int(p[l])) / 2
		l += 2
	print(int(c))


import sys
n = list(map(int, sys.stdin.readline().split(' ')))[0]
a = list(sys.stdin.readline())
x = list(map(int, sys.stdin.readline().split(' ')))
m = 100000000000
for i in range(n - 1):
	if a[i] == 'R' and a[i + 1] == 'L':
		m = min(m, (x[i + 1] - x[i]) / 2)
if m == 100000000000:
	m = -1
print(int(m))


n = int(input())
s = str(input())
index = list(map(int, input().split()))
i = 0
ans = 9999999999999
while i < len(s) - 1:
	if s[i] == 'R' and s[i + 1] == 'L':
		ans = min(ans, (index[i + 1] - index[i]) // 2)
	i = i + 1
if ans == 9999999999999:
	print(-1)
else:
	print(ans)


n = int(input())
s = input()
x = list(map(int, input().split()))
ans = 1000000001
r = s.find('R')
l = s.find('L')
if r != -1 and l != -1:
	for i in range(0, n):
		if s[i] == 'R':
			r = i
		if s[i] == 'L':
			l = i
		if r < l:
			ans = min(ans, (x[l] - x[r]) // 2)
if ans == 1000000001:
	ans = -1
print(ans)


n = int(input())
directions = list(input())
positions = list(map(int, input().split()))
times = []
for i in range(n - 1):
	if directions[i] == 'R' and directions[i + 1] == 'L':
		times.append((positions[i + 1] - positions[i]) // 2)
print(min(times) if len(times) > 0 else -1)


def main():
	n = int(input())
	directions = input()
	x = [int(y) for y in input().split()]
	last_r = -1
	res = -1
	for i in range(0, n):
		if directions[i] == 'L':
			if last_r != -1:
				res = res >= 0 and min(res, (x[i] - x[last_r]) // 2) or (x[i] - x[last_r]) // 2
		else:
			last_r = i
	print(res)
main()


(n,) = map(int, input().split())
d = input()
arr = list(map(int, input().split()))
ans = float('inf')
for i in range(1, n):
	if d[i] == 'L' and d[i - 1] == 'R':
		ans = min(ans, (arr[i] - arr[i - 1]) // 2)
print(ans if ans < float('inf') else -1)


import math
N = int(input())
directions = [x for x in input().split()]
speeds = [int(x) for x in input().split()]
min = 1000000000
found = 0
for x in range(0, len(directions[0]) - 1):
	if directions[0][x] == 'R' and directions[0][x + 1] == 'L':
		time = (speeds[x + 1] - speeds[x]) / 2
		if time < min:
			min = time
			found = 1
if found == 0:
	print('-1')
else:
	print(math.floor(min))


try:
	_ = input()
	s = input()
	a = list(map(int, input().split()))
	ans = float('inf')
	for i in range(0, len(a) - 1):
		if s[i] == 'R' and s[i + 1] == 'L':
			ans = min(ans, (a[i + 1] - a[i]) // 2)
	if ans == float('inf'):
		print(-1)
		exit(0)
	print(ans)
except:
	pass


n = int(input())
s = input()
L = [int(i) for i in input().split()]
low = []
for i in range(n - 1):
	if s[i] + s[i + 1] == 'RL':
		low.append((L[i + 1] - L[i]) // 2)
x = [str(i) for i in low]
x = ''.join(x)
print(min(low) if x != '' else '-1')


n = int(input())
s = input()
x = list(map(int, input().split()))
t = []
flag = False
for i in range(len(s) - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		t.append(i)
		flag = True
if flag == False:
	print(-1)
else:
	a = []
	for i in t:
		a.append(x[i + 1] - x[i])
	print(min(a) // 2)


n = int(input())
directions = input()
positions = [int(c) for c in input().split()]
collisions = []
for i in range(len(directions) - 1):
	if directions[i] == 'R' and directions[i + 1] == 'L':
		collisions.append((positions[i + 1] - positions[i]) // 2)
if not collisions:
	print(-1)
else:
	print(min(collisions))


n = int(input())
s = input()
x = list(map(int, input().split()))
ans = float('inf')
last = None
for i in range(n):
	if s[i] == 'R':
		last = x[i]
	elif last != None:
		cur = (x[i] - last) // 2
		ans = min(ans, cur)
if ans == float('inf'):
	ans = -1
print(ans)


n = int(input())
s = input()
x = list(map(int, input().split(' ')))
Min = 10000000000000
for i in range(0, n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		Min = min(Min, (x[i + 1] - x[i]) // 2)
print(Min if Min != 10000000000000 else -1)


def main():
	n_particles = int(input())
	movements = input()
	positions = [int(_) for _ in input().split()]
	happened = -1
	for i in range(n_particles - 1):
		if movements[i] == 'R' and movements[i + 1] == 'L':
			will_happen_in = (positions[i + 1] - positions[i]) // 2
			if happened == -1 or will_happen_in < happened:
				happened = will_happen_in
	print(happened)
main()


n = int(input())
moves = input()
objects = input().split()
objects = [int(el) for el in objects]

def leftElIndex(i, n):
	return -1 if i - 1 < 0 else i - 1

def rightElIndex(i, n):
	return -1 if i + 1 >= n else i + 1

def collidesInSteps(i, j):
	if j == -1 or moves[i] == moves[j] or (moves[i] == 'L' and moves[j] == 'R'):
		return -1
	distance = abs(objects[i] - objects[j])
	return int(distance / 2) if distance % 2 == 0 else -1
collides = 0
for i in range(n):
	rightIndex = rightElIndex(i, n)
	rightCollides = collidesInSteps(i, rightIndex)
	if rightCollides != -1:
		collides = rightCollides if collides == 0 else min(rightCollides, collides)
if collides == 0:
	print('-1')
else:
	print(collides)


n = int(input())
s = list(input())
l = list(map(int, input().split()))
ans = 11 ** 11
for i in range(n - 1):
	if s[i] == 'R' and s[i + 1] == 'L':
		t = (l[i + 1] - l[i]) // 2
		if ans > t:
			ans = t
if ans == 11 ** 11:
	print(-1)
else:
	print(ans)


n = int(input())
s = input()
x = list(map(int, input().split()))
p = sorted([(x[i], s[i]) for i in range(n)])
ans = -1
mi = 10 ** 10
for i in range(1, n):
	if p[i - 1][1] == 'R' and p[i][1] == 'L' and (p[i][0] - p[i - 1][0] < mi):
		mi = p[i][0] - p[i - 1][0]
		ans = mi // 2
print(ans)


n = int(input())
s = input()
c = list(map(int, input().split()))
l = 10 ** 10
for i in range(1, n):
	if s[i] == 'L' and s[i - 1] == 'R':
		l = min(l, c[i] - c[i - 1])
if l == 10 ** 10:
	print(-1)
else:
	print(l // 2)


def main():
	n = input()
	s = input()
	L = [int(x) for x in input().split()]
	print(solver(s, L))

def solver(s, L):
	minimum = -1
	for i in range(len(s) - 1):
		if s[i:i + 2] == 'RL':
			cur = (L[i + 1] - L[i]) // 2
			if minimum == -1 or cur < minimum:
				minimum = cur
	return minimum
main()


import re
Input = lambda : map(int, input().split())
n = int(input())
s = input()
l = list(Input())
s = re.sub('RL', '??', s)
i = 0
MIN = float('inf')
while i < n:
	if s[i] == '?':
		MIN = min(MIN, (l[i + 1] - l[i]) // 2)
		i += 2
	else:
		i += 1
print(MIN if MIN != float('inf') else -1)


n = int(input())
ways = input()
cordinates = list(map(int, input().split()))
distances = []
for i in range(0, n - 1):
	if ways[i] == 'R' and ways[i + 1] == 'L':
		distances.append(cordinates[i + 1] - cordinates[i])
if len(distances) > 0:
	x = min(distances)
	print(int(x * 0.5))
else:
	print('-1')


input()
l = list(input())
x = list(map(int, input().split(' ')))
p = [i for i in range(len(l) - 1) if l[i] == 'R' and l[i + 1] == 'L']
if not p:
	print(-1)
else:
	t = [x[i + 1] - x[i] for i in p]
	print(min(t) // 2)


def main():
	n = int(input())
	d = input()
	x = list(map(int, input().split()))
	t = -1
	for i in range(len(x) - 1):
		if d[i] == 'R' and d[i + 1] == 'L':
			time = (x[i] + x[i + 1]) // 2 - x[i]
			t = min(10000000000.0 if t < 0 else t, time)
	print(t)
main()