fun main(){ val n = readLine()!!.toInt() val s = readLine()!! val a = mutableListOf() a += readLine()!!.split(" ").map{it.toLong()} for(i in 0..n-1){ if(s[i] == 'R') a[i] = a[i] * -1L if(i > 0) a[i] += a[i-1] } var answer = Math.abs(a[0]) var befmin = Math.min(0, a[0]) var befmax = Math.max(0, a[0]) for(i in 1..n-1){ answer = Math.max(answer, Math.max(Math.abs(befmin-a[i]), Math.abs(befmax-a[i]))) befmin = Math.min(befmin, a[i]) befmax = Math.max(befmax, a[i]) } println(answer) }