#include <bits/stdc++.h>   int min(int a, int b) { return a < b ? a : b; }   int max(int a, int b) { return a > b ? a : b; }   int oo[1 + (50 + 50 * 26 + 26) * 2], oh[1 + (50 + 50 * 26 + 26) * 2];   int link(int o, int h) {     static int _ = 1;     oo[_] = o, oh[_] = h;     return _++;   }   int ii[(50 + 50 * 26 + 26)], jj[(50 + 50 * 26 + 26)],       cc[(50 + 50 * 26 + 26) * 2], ww[(50 + 50 * 26 + 26)],       ww_[(50 + 50 * 26 + 26)], m_;   int ae[(1 + 50 + 26 + 1)], dd[(1 + 50 + 26 + 1)], kk[(1 + 50 + 26 + 1)],       ff[(1 + 50 + 26 + 1)], n_;   int pq[1 + (1 + 50 + 26 + 1)], iq[(1 + 50 + 26 + 1)], cnt;   void link_(int i, int j, int c, int w) {     int h = m_++;     ii[h] = i, jj[h] = j, cc[h << 1] = c;     ww[h] = w;     ae[i] = link(ae[i], h << 1);     ae[j] = link(ae[j], h << 1 | 1);   }   int less(int u, int v) {     return dd[u] < dd[v] || dd[u] == dd[v] && kk[u] < kk[v];   }   int i2(int i) {     return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;   }   void pq_up(int u) {     int i, j, v;     for (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j) pq[iq[v] = i] = v;     pq[iq[u] = i] = u;   }   void pq_dn(int u) {     int i, j, v;     for (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j) pq[iq[v] = i] = v;     pq[iq[u] = i] = u;   }   void pq_add_last(int u) { pq[iq[u] = ++cnt] = u; }   int pq_remove_first() {     int u = pq[1], v = pq[cnt--];     if (v != u) iq[v] = 1, pq_dn(v);     iq[u] = 0;     return u;   }   int dijkstra(int s, int t) {     memset(dd, 0x3f, n_ * sizeof *dd);     dd[s] = 0, pq_add_last(s);     while (cnt) {       int i, k, o;       i = pq_remove_first();       k = kk[i] + 1;       for (o = ae[i]; o; o = oo[o]) {         int h_ = oh[o];         if (cc[h_] > 0) {           int h = h_ >> 1, j = i ^ ii[h] ^ jj[h];           int d = dd[i] + ((h_ & 1) == 0 ? ww_[h] : -ww_[h]);           if (dd[j] > d || dd[j] == d && kk[j] > k) {             if (dd[j] == 0x3f3f3f3f) pq_add_last(j);             dd[j] = d, kk[j] = k, ff[j] = h_;             pq_up(j);           }         }       }     }     return dd[t] != 0x3f3f3f3f;   }   int trace(int s, int t) {     while (t != s) {       int h_ = ff[t], h = h_ >> 1;       cc[h_]--, cc[h_ ^ 1]++;       t ^= ii[h] ^ jj[h];     }     return 1;   }   int edmonds_karp(int s, int t) {     int h, f, cost;     for (h = 0; h < m_; h++) {       int i = ii[h], j = jj[h];       dd[j] = min(dd[j], dd[i] + ww[h]);     }     for (h = 0; h < m_; h++) {       int i = ii[h], j = jj[h];       ww_[h] = ww[h] + dd[i] - dd[j];     }     f = 0;     while (dijkstra(s, t)) {       f += trace(s, t);       for (h = 0; h < m_; h++) {         int i = ii[h], j = jj[h];         if (dd[i] != 0x3f3f3f3f && dd[j] != 0x3f3f3f3f) {           ww_[h] += dd[i] - dd[j];         }       }     }     cost = 0;     for (h = 0; h < m_; h++) cost += ww[h] * cc[h << 1 | 1];     return cost;   }   int main() {     static char cc[50 * 2 + 1];     static int bb[50 * 2], kk[26];     int n, i, a;     scanf( %d%s , &n, cc), n /= 2;     n_ = 1 + n + 26 + 1;     for (i = 0; i < n * 2; i++) scanf( %d , &bb[i]);     for (i = 0; i < n; i++) link_(0, 1 + i, 2, 0);     for (i = 0; i < n; i++) {       int j = n * 2 - 1 - i;       int ai = cc[i] -  a ;       int aj = cc[j] -  a ;       for (a = 0; a < 26; a++) {         int b;         if (a == ai && a == aj)           b = max(bb[i], bb[j]);         else if (a == ai)           b = bb[i];         else if (a == aj)           b = bb[j];         else           b = 0;         link_(1 + i, 1 + n + a, 1, -b);       }     }     for (i = 0; i < n * 2; i++) {       a = cc[i] -  a ;       kk[a]++;     }     for (a = 0; a < 26; a++) link_(1 + n + a, n_ - 1, kk[a], 0);     printf( %d n , -edmonds_karp(0, n_ - 1));     return 0;   }