#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
const long long inf = 1e15;
long long f[maxn][2], c[maxn];
string str[maxn];
string rev[maxn];
int main(void) {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> c[i];
  for (long long i = 1; i <= n + 10; i++) f[i][0] = f[i][1] = inf;
  f[1][0] = 0;
  f[1][1] = c[1];
  for (long long i = 1; i <= n; i++) {
    cin >> str[i];
    rev[i] = str[i];
    reverse(rev[i].begin(), rev[i].end());
  }
  for (long long i = 2; i <= n; i++) {
    if (str[i] >= str[i - 1]) {
      f[i][0] = min(f[i][0], f[i - 1][0]);
    }
    if (str[i] >= rev[i - 1]) {
      f[i][0] = min(f[i][0], f[i - 1][1]);
    }
    if (rev[i] >= str[i - 1]) {
      f[i][1] = min(f[i][1], f[i - 1][0] + c[i]);
    }
    if (rev[i] >= rev[i - 1]) {
      f[i][1] = min(f[i][1], f[i - 1][1] + c[i]);
    }
  }
  if (min(f[n][0], f[n][1]) == inf)
    cout << "-1" << endl;
  else
    cout << min(f[n][0], f[n][1]) << endl;
  return 0;
}
