#include <bits/stdc++.h>
using namespace std;
int arr[100001];
string str[100001];
long long int dp[100001][2];
int n;
long long int rec(int ind, int dir) {
  if (ind == n - 1) {
    if (dir == 0)
      return 0LL;
    else
      return (long long int)arr[ind];
  }
  if (dp[ind][dir] != -1) {
    return (long long int)dp[ind][dir];
  }
  long long int a = 1000000000000000LL;
  string dummy = str[ind + 1];
  string dum = str[ind];
  reverse(dum.begin(), dum.end());
  reverse(dummy.begin(), dummy.end());
  if (dir == 0) {
    if (str[ind] <= str[ind + 1]) {
      a = min(a, rec(ind + 1, 0));
    }
    if (str[ind] <= dummy) {
      a = min(a, rec(ind + 1, 1));
    }
    dp[ind][0] = a;
  } else {
    if (dum <= str[ind + 1]) {
      a = min(a, rec(ind + 1, 0));
    }
    if (dum <= dummy) {
      a = min(a, rec(ind + 1, 1));
    }
    dp[ind][1] = arr[ind] + a;
  }
  return (long long int)dp[ind][dir];
}
int main() {
  cin >> n;
  int i;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < n; i++) {
    cin >> str[i];
  }
  for (i = 0; i < n; i++) {
    dp[i][0] = -1;
    dp[i][1] = -1;
  }
  long long int ans = min(rec(0, 0), rec(0, 1));
  if (ans >= 1000000000000000LL)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
