#include <bits/stdc++.h>
using namespace std;
int dx[]{1, -1, 0, 0, 1, -1, 1, -1};
int dy[]{0, 0, 1, -1, 1, -1, -1, 1};
long long suf(long long x) { return (x * (x + 1)) / 2; }
vector<vector<pair<int, long long> > > adj;
const long long mod = 1e9 + 7, size = 1000006, oi = INT_MAX, ol = INT64_MAX;
int n, m, cur = 1;
vector<string> A, Ar;
vector<long long> v;
long long dp[100005][2];
long long go(int idx, bool ok) {
  if (idx == n) {
    if (ok == 0)
      return v[idx - 1];
    else
      return 0;
  }
  long long &ret = dp[idx][ok];
  if (ret != -1) return ret;
  ret = 1e15;
  if (ok == 0) {
    if (A[idx] >= Ar[idx - 1]) ret = min(ret, go(idx + 1, 1) + v[idx - 1]);
    if (Ar[idx] >= Ar[idx - 1]) ret = min(ret, go(idx + 1, 0) + v[idx - 1]);
  } else {
    if (A[idx] >= A[idx - 1]) ret = min(ret, go(idx + 1, 1));
    if (Ar[idx] >= A[idx - 1]) ret = min(ret, go(idx + 1, 0));
  }
  return ret;
}
int main() {
  double a, b, x, y;
  while (cin >> n) {
    stack<string> st;
    v.resize(n);
    for (int i = 0; i < n; i++) scanf("%I64d", &v[i]);
    string s;
    A.resize(n);
    Ar.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> A[i];
      Ar[i] = A[i];
      reverse(((Ar[i]).begin()), ((Ar[i]).end()));
    }
    memset(dp, -1, sizeof(dp));
    long long ans = min(go(1, 0), go(1, 1));
    if (ans == 1e15)
      cout << "-1" << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
