#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100005];
string ss[100005];
long long memo[100005][2][2];
long long solve(int u = 0, bool x = 0, bool ok = true) {
  long long ret = 1e18;
  if (u == n - 1) return 0;
  if (memo[u][x][ok] != -1) return memo[u][x][ok];
  string curr;
  if (!x) {
    curr = ss[u];
  } else {
    for (int i = 0; i < ss[u].size(); i++) curr = ss[u][i] + curr;
  }
  string next = ss[u + 1];
  string rev;
  for (int i = 0; i < next.size(); i++) rev = next[i] + rev;
  if (strcmp(curr.c_str(), next.c_str()) <= 0)
    ret = min(ret, solve(u + 1, 0, ok));
  if (strcmp(curr.c_str(), rev.c_str()) <= 0)
    ret = min(ret, a[u + 1] + solve(u + 1, 1, ok));
  rev = "";
  for (int i = 0; i < curr.size(); i++) rev = curr[i] + rev;
  if (u == 0 && ok) ret = min(ret, a[u] + solve(u, 1, false));
  return memo[u][x][ok] = ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    cin >> ss[i];
  }
  memset(memo, -1, sizeof memo);
  long long ans = solve();
  if (ans >= 1e18)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
