#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1e5 + 5);
const long long LINF = (long long)(1e15);
int n, c[N];
long long f[N][2];
string s0[N], s1[N];
bool minimize(long long &a, long long b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> c[i];
  for (int i = 1; i <= n; ++i) {
    cin >> s0[i];
    s1[i] = s0[i];
    reverse(s1[i].begin(), s1[i].end());
  }
  for (int i = 1; i <= n; ++i)
    for (int cur = 0; cur < 2; ++cur) f[i][cur] = LINF;
  f[1][0] = 0;
  f[1][1] = c[1];
  for (int i = 1; i <= n - 1; ++i)
    for (int cur = 0; cur < 2; ++cur) {
      if (cur == 0) {
        if (s0[i + 1] >= s0[i]) minimize(f[i + 1][0], f[i][cur]);
        if (s1[i + 1] >= s0[i]) minimize(f[i + 1][1], f[i][cur] + c[i + 1]);
      } else {
        if (s0[i + 1] >= s1[i]) minimize(f[i + 1][0], f[i][cur]);
        if (s1[i + 1] >= s1[i]) minimize(f[i + 1][1], f[i][cur] + c[i + 1]);
      }
    }
  long long ans = LINF;
  for (int cur = 0; cur < 2; ++cur) minimize(ans, f[n][cur]);
  cout << (ans == LINF ? -1 : ans);
  return 0;
}
