#include <bits/stdc++.h>
using namespace std;
const int MAXN = int(2e3);
const int LOG2 = 14;
const int MOD = int(1e9) + 7;
const int oo = INT_MAX;
int n, tc;
int ans1, ans2, ans3;
string s;
int a[255];
int mn[MAXN][LOG2];
int seen[MAXN][MAXN];
int dp1[MAXN][MAXN];
int dp3[MAXN][MAXN];
void build() {
  for (int i = 0; i < n; i++) {
    mn[i][0] = a[s[i] - 'a'];
  }
  for (int j = 1; j < LOG2; j++) {
    for (int i = 0; i + (1 << (j - 1)) < n; i++) {
      mn[i][j] = min(mn[i][j - 1], mn[i + (1 << (j - 1))][j - 1]);
    }
  }
}
int query(int f, int t) {
  int j = 31 - __builtin_clz(t - f + 1);
  return min(mn[f][j], mn[t - (1 << j) + 1][j]);
}
void go(int i, int len) {
  ans2 = max(ans2, len);
  if (i == n) {
    dp1[i][len] = 1;
    dp3[i][len] = 1;
    return;
  }
  if (seen[i][len] == tc) return;
  seen[i][len] = tc;
  int r = 0, m = oo;
  int q = query(i - len, i);
  if (len + 1 <= q) {
    go(i + 1, len + 1);
    r += dp1[i + 1][len + 1];
    if (r >= MOD) r -= MOD;
    m = min(m, dp3[i + 1][len + 1]);
  }
  {
    go(i + 1, 1);
    r += dp1[i + 1][1];
    if (r >= MOD) r -= MOD;
    m = min(m, 1 + dp3[i + 1][1]);
  }
  dp1[i][len] = r;
  dp3[i][len] = m;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (tc = 1; cin >> n >> s; tc++) {
    for (int i = 0; i < 26; i++) cin >> a[i];
    build();
    ans2 = 0;
    go(1, 1);
    cout << dp1[1][1] << "\n" << ans2 << "\n" << dp3[1][1] << "\n";
  }
  return 0;
}
