#include <bits/stdc++.h>
using namespace std;
long long gcd_ll(long long a, long long b) { return a ? gcd_ll(b % a, a) : b; }
long long lcm_ll(long long a, long long b) { return (a / gcd_ll(a, b)) * b; }
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
int lcm(int a, int b) { return (a / gcd(a, b)) * b; }
string int_to_str_easy(long long n) {
  return n ? "" : int_to_str_easy(n / 10) + (char)('0' + n % 10);
}
long long sum(vector<long long> v) {
  long long ans = 0;
  for (long long i : v) ans += i;
  return ans;
}
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }
string follow(string s) {
  for (int i = 0; i < s.length(); i++)
    if (is_upper(s[i])) s[i] += 'a' - 'A';
  return s;
}
const long double pi = 3.141592653589793238462643383279;
const long double log23 = 1.58496250072115618145373894394781;
const long double eps = 1e-8;
const long double zero = 0;
const long long INF = 1e18;
const int COUT = 30;
const int prost = 239;
const long long prost64 = 239;
const long long MOD = 1000000007;
const int BIG = 1e9;
const int alf = 26;
const int MAX_N = 2e5 + 1;
const int MAX_M = 2001;
const int km = (1 << 18) - 1;
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
void solve() { return; }
long long n, c[MAX_N], dp[2][MAX_N];
string s1[MAX_N], s2[MAX_N];
int main() {
  cin.sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) cin >> s2[i];
  for (int i = 0; i < n; i++) {
    s1[i] = s2[i];
    reverse(s2[i].begin(), s2[i].end());
  }
  dp[0][0] = 0;
  dp[1][0] = c[0];
  for (int i = 1; i < n; i++) {
    dp[0][i] = INF;
    dp[1][i] = INF;
    if (s1[i] >= s1[i - 1]) dp[0][i] = min(dp[0][i], dp[0][i - 1]);
    if (s2[i] >= s1[i - 1]) dp[1][i] = min(dp[1][i], dp[0][i - 1] + c[i]);
    if (s1[i] >= s2[i - 1]) dp[0][i] = min(dp[0][i], dp[1][i - 1]);
    if (s2[i] >= s2[i - 1]) dp[1][i] = min(dp[1][i], dp[1][i - 1] + c[i]);
  }
  long long ans = min(dp[1][n - 1], dp[0][n - 1]);
  if (ans >= INF - 239) ans = -1;
  cout << ans;
  return 0;
}
