#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const long long mod = 1000 * 1000 * 1000 + 7;
const long long inf = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const long long mod2 = 998244353;
const long long N = 1000 + 10;
const long double pi = 3.141592653589793;
long long power(long long x, long long y, long long p = LLONG_MAX) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long ncr(long long n, long long r, long long m) {
  if (r > n) return 0;
  long long a = 1, b = 1, i;
  for (i = 0; i < r; i++) {
    a = (a * n) % m;
    --n;
  }
  while (r) {
    b = (b * r) % m;
    --r;
  }
  return (a * power(b, m - 2, m)) % m;
}
template <typename T>
istream &operator>>(istream &in, vector<T> &v) {
  for (auto &i : v) cin >> i;
  return in;
}
template <typename T>
istream &operator>>(istream &in, pair<T, T> &p) {
  cin >> p.first >> p.second;
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &v) {
  for (auto &i : v) cout << i << " ";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, pair<T, T> &p) {
  cout << p.first << " " << p.second << " ";
  return out;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> c(n);
  for (long long i = 0; i < n; i++) cin >> c[i];
  string s[n], rs[n];
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
    rs[i] = s[i];
    reverse(rs[i].begin(), rs[i].end());
  }
  long long dp[n][2];
  dp[0][0] = 0;
  dp[0][1] = c[0];
  for (long long i = 1; i < n; i++) {
    if (dp[i - 1][0] == -1 && dp[i - 1][1] == -1) {
      dp[i][0] = -1;
      dp[i][1] = -1;
    } else if (dp[i - 1][0] == -1) {
      if (s[i] >= rs[i - 1]) {
        dp[i][0] = dp[i - 1][1];
      } else {
        dp[i][0] = -1;
      }
      if (rs[i] >= rs[i - 1]) {
        dp[i][1] = dp[i - 1][1] + c[i];
      } else {
        dp[i][1] = -1;
      }
    } else if (dp[i - 1][1] == -1) {
      if (s[i] >= s[i - 1]) {
        dp[i][0] = dp[i - 1][0];
      } else {
        dp[i][0] = -1;
      }
      if (rs[i] >= s[i - 1]) {
        dp[i][1] = dp[i - 1][0] + c[i];
      } else {
        dp[i][1] = -1;
      }
    } else {
      dp[i][0] = inf;
      dp[i][1] = inf;
      if (s[i] >= s[i - 1]) {
        dp[i][0] = dp[i - 1][0];
      }
      if (s[i] >= rs[i - 1]) {
        dp[i][0] = min(dp[i][0], dp[i - 1][1]);
      }
      if (rs[i] >= s[i - 1]) {
        dp[i][1] = dp[i - 1][0] + c[i];
      }
      if (rs[i] >= rs[i - 1]) {
        dp[i][1] = min(dp[i][1], dp[i - 1][1] + c[i]);
      }
      if (dp[i][0] == inf) dp[i][0] = -1;
      if (dp[i][1] == inf) dp[i][1] = -1;
    }
  }
  if (dp[n - 1][0] == -1 && dp[n - 1][1] == -1)
    cout << -1;
  else if (dp[n - 1][0] == -1)
    cout << dp[n - 1][1];
  else if (dp[n - 1][1] == -1)
    cout << dp[n - 1][0];
  else
    cout << min(dp[n - 1][0], dp[n - 1][1]);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
