#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int arr[26];
string s;
long long dp[1001][1001];
int mn = 1 << 20, mx = 0;
long long solve(int idx, int sz, int mn) {
  if (sz > mn) return 0;
  mx = max(mx, sz);
  if (idx == n) return 1;
  if (dp[idx][sz] != -1) return dp[idx][sz] % 1000000007;
  if (sz < mn) {
    long long a = solve(idx + 1, 1, arr[s[idx] - 'a']);
    return dp[idx][sz] =
               (a + solve(idx + 1, sz + 1, min(mn, arr[s[idx] - 'a']))) %
               1000000007;
  } else
    return dp[idx][sz] = solve(idx + 1, 1, arr[s[idx] - 'a']) % 1000000007;
}
long long solve2(int idx, int sz, int mn) {
  if (sz > mn) return 1 << 20;
  if (idx == n) {
    return 0;
  }
  if (dp[idx][sz] != -1) return dp[idx][sz];
  if (sz < mn) {
    long long a = solve2(idx + 1, 1, arr[s[idx] - 'a']) + 1;
    return dp[idx][sz] =
               min(a, solve2(idx + 1, sz + 1, min(mn, arr[s[idx] - 'a'])));
  } else
    return dp[idx][sz] = solve2(idx + 1, 1, arr[s[idx] - 'a']) + 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(dp, -1, sizeof dp);
  cin >> n;
  cin >> s;
  for (int i = 0; i < 26; i++) {
    cin >> arr[i];
  }
  cout << solve(1, 1, arr[s[0] - 'a']) % 1000000007 << endl;
  ;
  cout << mx << endl;
  memset(dp, -1, sizeof dp);
  cout << solve2(1, 1, arr[s[0] - 'a']) + 1 << endl;
}
