#include <bits/stdc++.h>
using namespace std;
const int nmax = 200010;
const long long inf = 1ll * 100000000000000000;
int n;
long long c[nmax];
string ss;
string s[nmax][2];
long long dp[nmax][2];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) {
    cin >> s[i][0];
    s[i][1] = s[i][0];
    reverse(s[i][1].begin(), s[i][1].end());
  }
  dp[0][0] = 0;
  dp[0][1] = c[0];
  for (int i = 1; i < n; i++) {
    dp[i][0] = dp[i][1] = inf;
    for (int op = 0; op <= 1; op++)
      for (int pr = 0; pr <= 1; pr++)
        if (s[i - 1][pr] <= s[i][op])
          dp[i][op] = min(dp[i][op], dp[i - 1][pr] + c[i] * (op == 1));
  }
  long long ans = min(dp[n - 1][0], dp[n - 1][1]);
  cout << (ans == inf ? -1 : ans) << endl;
}
