#include <bits/stdc++.h>
using namespace std;
long double pi = 3.14159265358979;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 5;
long long dp[N][2];
void solve() {
  long long n;
  cin >> n;
  long long c[n];
  for (long long i = 0; i < n; i++) cin >> c[i];
  string a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) {
    if (!i)
      dp[i][1] = c[i];
    else {
      string s = a[i], b = a[i - 1];
      if (dp[i - 1][0] != -1) {
        if (s >= b)
          dp[i][0] = dp[i - 1][0];
        else
          dp[i][0] = -1;
        reverse((s).begin(), (s).end());
        if (s >= b)
          dp[i][1] = dp[i - 1][0] + c[i];
        else
          dp[i][1] = -1;
      } else {
        dp[i][0] = -1;
        dp[i][1] = -1;
      }
      s = a[i];
      reverse((b).begin(), (b).end());
      if (dp[i - 1][1] != -1) {
        if (s >= b) {
          if (dp[i][0] != -1)
            dp[i][0] = min(dp[i][0], dp[i - 1][1]);
          else
            dp[i][0] = dp[i - 1][1];
        } else
          dp[i][0] = max(dp[i][0], -1ll);
        reverse((s).begin(), (s).end());
        if (s >= b) {
          if (dp[i][1] != -1)
            dp[i][1] = min(dp[i][1], dp[i - 1][1] + c[i]);
          else
            dp[i][1] = dp[i - 1][1] + c[i];
        } else
          dp[i][1] = max(dp[i][1], -1ll);
      } else {
        dp[i][0] = max(dp[i][0], -1ll);
        dp[i][1] = max(dp[i][1], -1ll);
      }
    }
  }
  if (dp[n - 1][0] == -1 && dp[n - 1][1] == -1)
    cout << -1;
  else {
    if (dp[n - 1][0] == -1 || dp[n - 1][1] == -1)
      cout << max(dp[n - 1][0], dp[n - 1][1]);
    else
      cout << min(dp[n - 1][0], dp[n - 1][1]);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long tc = 1;
  while (tc--) {
    solve();
    cout << '\n';
  }
  return 0;
}
