#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
int dp[1010];
char s[1010];
int a[1010], fr[1010];
int main() {
  int n;
  cin >> n;
  scanf("%s", s + 1);
  for (int i = 0; i < 26; i++) scanf("%d", &a[i]);
  dp[0] = 1;
  int Max = 0;
  for (int i = 1; i <= n; i++) {
    int idx = i, Min = i - a[s[i] - 'a'] + 1;
    while (idx - 1 > 0 && (idx - 1) >= Min) {
      if (i - (idx - 1) + 1 > a[s[idx - 1] - 'a']) break;
      idx--;
      Min = max(Min, i - a[s[idx] - 'a'] + 1);
    }
    Max = max(Max, i - idx + 1);
    fr[i] = idx;
    for (int j = idx; j <= i; j++) dp[i] += dp[j - 1], dp[i] %= mod;
  }
  int now = n, cnt = 0;
  while (now > 0) {
    now = fr[now] - 1;
    cnt++;
  }
  cout << dp[n] << endl;
  cout << Max << endl;
  cout << cnt << endl;
  return 0;
}
