#include <bits/stdc++.h>
using namespace std;
bool Check(int N, int pos) { return (bool)(N & (1 << pos)); }
int Set(int N, int pos) { return (N | (1 << pos)); }
int fx[] = {-1, 0, 1, 0};
int fy[] = {0, 1, 0, -1};
inline long long BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return R;
}
const long long mod = 1e9 + 7;
long long n;
string str;
long long dp[1005], ara[30];
long long cp[1005];
long long mx;
long long call(int pos) {
  if (pos == n) return 1;
  if (dp[pos] != -1) return dp[pos];
  long long ret = 0;
  long long range = n;
  long long len = 0;
  for (int i = pos; i < n and i < range; i++) {
    int ch = str[i] - 'a';
    range = min(range, pos + (ara[ch]));
    if (i >= range) break;
    len++;
    mx = max(mx, len);
    ret += call(i + 1);
    ret %= mod;
  }
  return dp[pos] = ret % mod;
}
long long fall(int pos) {
  if (pos == n) return 0;
  if (cp[pos] != -1) return cp[pos];
  long long ret = 100000000;
  long long range = n;
  for (int i = pos; i < n and i < range; i++) {
    int ch = str[i] - 'a';
    range = min(range, pos + (ara[ch]));
    if (i >= range) break;
    ret = min(ret, 1 + fall(i + 1));
  }
  return cp[pos] = ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  memset(dp, -1, sizeof(dp));
  memset(cp, -1, sizeof(cp));
  cin >> n;
  cin >> str;
  for (int i = 0; i < 26; i++) cin >> ara[i];
  cout << call(0) << "\n";
  cout << mx << "\n";
  cout << fall(0) << "\n";
}
