#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const int N = 1e3 + 10;
int s[4 * N];
string str;
long long dp[N][N];
int dp2[N];
int freq[30];
void build(int curr, int l, int r) {
  if (l == r) {
    s[curr] = freq[str[l] - 'a' + 1];
    return;
  }
  int c1 = curr << 1, c2 = c1 | 1, mid = l + r >> 1;
  build(c1, l, mid);
  build(c2, mid + 1, r);
  s[curr] = min(s[c1], s[c2]);
}
int query(int curr, int l, int r, int x, int y) {
  if (l > y || r < x) return 1010;
  if (x <= l && r <= y) {
    return s[curr];
  }
  int c1 = curr << 1, c2 = c1 | 1, mid = l + r >> 1;
  int q = min(query(c1, l, mid, x, y), query(c2, mid + 1, r, x, y));
  return q;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  memset(dp, 0, sizeof(dp));
  int n;
  cin >> n;
  cin >> str;
  str = 'a' + str;
  for (int i = 1; i <= n; ++i) dp2[i] = 1010;
  for (int i = 1; i <= 26; ++i) cin >> freq[i];
  build(1, 1, n);
  dp[1][1] = 1;
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= i - 1; ++j) {
      if (query(1, 1, n, j, i) >= (i - j + 1))
        dp[i][j] = dp[i - 1][j];
      else
        dp[i][j] = 0;
    }
    for (int j = 1; j <= i - 1; ++j) {
      dp[i][i] = (dp[i][i] % mod + dp[i - 1][j] % mod) % mod;
      if (dp[i][i] < 0) dp[i][i] += mod;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = (ans % mod + dp[n][i] % mod) % mod;
    if (ans < 0) ans += mod;
  }
  int ans2 = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= i; ++j) {
      if (dp[i][j] > 0) ans2 = max(ans2, i - j + 1);
    }
  dp2[0] = 0;
  dp2[1] = 1;
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= i; ++j) {
      if (dp[i][j] > 0) {
        dp2[i] = min(dp2[j - 1] + 1, dp2[i]);
      }
    }
  }
  cout << ans << endl;
  cout << ans2 << endl;
  cout << dp2[n];
  return 0;
}
