#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10, inf = 1e17 + 10;
long long a[N];
long long dp[N][2];
string s[N];
int32_t main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> s[0];
  dp[0][1] = a[0];
  dp[0][0] = 0;
  for (long long i = 1; i < N; i++) {
    dp[i][1] = inf;
    dp[i][0] = inf;
  }
  for (long long i = 1; i < n; i++) {
    cin >> s[i];
    string c = s[i - 1];
    string b = s[i];
    if (b >= c) {
      dp[i][0] = min(dp[i][0], dp[i - 1][0]);
    }
    reverse(s[i].begin(), s[i].end());
    reverse(s[i - 1].begin(), s[i - 1].end());
    if (s[i] >= c) {
      dp[i][1] = min(dp[i][1], dp[i - 1][0] + a[i]);
    }
    if (b >= s[i - 1]) {
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    }
    if (s[i] >= s[i - 1]) {
      dp[i][1] = min(dp[i][1], dp[i - 1][1] + a[i]);
    }
    reverse(s[i].begin(), s[i].end());
    reverse(s[i - 1].begin(), s[i - 1].end());
  }
  if (min(dp[n - 1][0], dp[n - 1][1]) >= inf) {
    cout << -1 << endl;
    return 0;
  }
  cout << min(dp[n - 1][1], dp[n - 1][0]) << endl;
  return 0;
}
