#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::map;
using std::max;
using std::min;
using std::multiset;
using std::pair;
using std::queue;
using std::reverse;
using std::set;
using std::sort;
using std::string;
using std::swap;
using std::vector;
const long long LINF = 1ll << 60;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 100000 + 10;
long long d[maxn][2];
long long c[maxn];
bool t[maxn][2], s[maxn][2];
long long dp(long long i, int b) {
  if (d[i][b] >= 0) return d[i][b];
  d[i][b] = 0;
  if (b == 0) {
    return d[i][b] = min((s[i][0] ? dp(i - 1, 0) : LINF),
                         (s[i][1] ? dp(i - 1, 1) : LINF));
  }
  return d[i][b] = min((t[i][0] ? dp(i - 1, 0) : LINF),
                       (t[i][1] ? dp(i - 1, 1) : LINF)) +
                   c[i];
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  memset(d, -1, sizeof(d));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  string str[2];
  string t_str[2];
  cin >> str[0];
  t_str[0] = str[0];
  reverse(t_str[0].begin(), t_str[0].end());
  t[0][0] = t[0][1] = s[0][0] = s[0][1] = true;
  int cur = 0;
  for (int i = 1; i < n; i++) {
    cur ^= 1;
    cin >> str[cur];
    t_str[cur] = str[cur];
    reverse(t_str[cur].begin(), t_str[cur].end());
    if (str[cur] >= str[cur ^ 1]) s[i][0] = true;
    if (str[cur] >= t_str[cur ^ 1]) s[i][1] = true;
    if (t_str[cur] >= str[cur ^ 1]) t[i][0] = true;
    if (t_str[cur] >= t_str[cur ^ 1]) t[i][1] = true;
  }
  d[0][0] = 0;
  d[0][1] = c[0];
  long long ans = min(dp(n - 1, 0), dp(n - 1, 1));
  if (ans == LINF) ans = -1;
  printf("%lld\n", ans);
}
