#include <bits/stdc++.h>
using namespace std;
int n;
string str[100100];
bool has_dp[100100][2];
long long dp[100100][2], c[100100];
bool smaller(int a, int b, bool changed_a, bool changed_b) {
  if (!a) return true;
  for (int i = 0; i < str[a].length() && i < str[b].length(); i++) {
    int ii = changed_a ? str[a].length() - 1 - i : i,
        jj = changed_b ? str[b].length() - 1 - i : i;
    if (str[a][ii] < str[b][jj]) {
      return true;
    }
    if (str[a][ii] > str[b][jj]) {
      return false;
    }
  }
  return str[a].length() <= str[b].length();
}
long long best(int index, bool changed) {
  if (index == n + 1) return 0ll;
  if (has_dp[index][changed]) return dp[index][changed];
  bool can1 = smaller(index - 1, index, changed, false),
       can2 = smaller(index - 1, index, changed, true);
  long long b = 1000000000000000000ll;
  if (can1) {
    long long ret1 = best(index + 1, false);
    if (ret1 != -1) b = min(b, ret1);
  }
  if (can2) {
    long long ret2 = best(index + 1, true);
    if (ret2 != -1) b = min(b, c[index] + ret2);
  }
  has_dp[index][changed] = true;
  return dp[index][changed] = (b == 1000000000000000000ll ? -1ll : b);
}
int main() {
  cin >> n;
  c[0] = 0;
  for (int i = 1; i <= n; i++) cin >> c[i];
  getline(cin, str[0]);
  for (int i = 1; i <= n; i++) getline(cin, str[i]);
  memset(has_dp, false, sizeof(has_dp));
  cout << best(1, false);
  return 0;
}
