#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
using namespace std::chrono;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  long long int a[26];
  for (int i = 0; i < 26; i++) cin >> a[i];
  long long int maxx = -1, len = 0, minn;
  vector<long long int> dp(n + 1, 0), dp2(n + 1, 1e12);
  for (int i = 0; i < n; i++) {
    minn = 1e12;
    for (int j = i; j >= 0; j--) {
      len = i - j + 1;
      minn = min(minn, a[s[j] - 'a']);
      if (minn < len) break;
      long long int x = j - 1 >= 0 ? dp[j - 1] : 1;
      dp[i] = (dp[i] + x) % mod;
      maxx = max(maxx, len);
      x = j - 1 >= 0 ? dp2[j - 1] : 0;
      dp2[i] = min(dp2[i], x + 1);
    }
  }
  cout << dp[n - 1] % mod << endl << maxx << endl << dp2[n - 1];
  return 0;
}
