#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const long long oo = 1e18 + 10;
long long n, c[N], f[2][N], dp[2][N];
string a[N];
map<string, long long> m;
int main() {
  scanf("%I64d", &n);
  for (long long i = 1, _b = (n); i <= _b; i++) {
    scanf("%I64d", &c[i]);
  }
  vector<string> t;
  for (long long i = 1, _b = (n); i <= _b; i++) {
    cin >> a[i];
    t.push_back(a[i]);
    string b = a[i];
    reverse(b.begin(), b.end());
    t.push_back(b);
  }
  sort(t.begin(), t.end());
  for (long long i = 0, _b = (t.size() - 1); i <= _b; i++) {
    m[t[i]] = i + 1;
  }
  for (long long i = 1, _b = (n); i <= _b; i++) {
    f[0][i] = m[a[i]];
    string b = a[i];
    reverse(b.begin(), b.end());
    f[1][i] = m[b];
  }
  for (long long i = 1, _b = (n); i <= _b; i++)
    for (long long typ = 0, _b = (1); typ <= _b; typ++) dp[typ][i] = oo;
  dp[0][1] = 0;
  dp[1][1] = c[1];
  for (long long i = 2, _b = (n); i <= _b; i++) {
    for (long long typ = 0, _b = (1); typ <= _b; typ++) {
      for (long long Lasttyp = 0, _b = (1); Lasttyp <= _b; Lasttyp++) {
        if (f[typ][i] >= f[Lasttyp][i - 1]) {
          dp[typ][i] = min(dp[typ][i], dp[Lasttyp][i - 1] + typ * c[i]);
        }
      }
    }
  }
  long long res = oo;
  res = min(res, min(dp[0][n], dp[1][n]));
  if (res == oo) res = -1;
  cout << res;
  return 0;
}
