#include <bits/stdc++.h>
using namespace std;
long long int dp[1005], dp2[1005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int i, j, n, ans2 = 0, m = 1000000007;
  cin >> n;
  string s;
  cin >> s;
  s = '*' + s;
  long long int a[30];
  for (i = 0; i < 26; i++) cin >> a[i];
  dp[0] = 1;
  for (i = 1; i <= n; i++) {
    long long int mn = a[s[i] - 'a'], flag = 0;
    dp2[i] = 2 * n;
    for (j = i; j >= 1; j--) {
      mn = min(mn, a[s[j] - 'a']);
      if (1 + i - j > mn) {
        flag = 1;
        break;
      }
      dp[i] = (dp[i] % m + dp[j - 1]) % m;
      dp2[i] = min(dp2[i], 1 + dp2[j - 1]);
    }
    ans2 = max(ans2, i - j);
  }
  cout << dp[n] << endl << ans2 << endl << dp2[n];
}
