#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void pp(T... args) {
  ((cout << args << " "), ...);
  cout << "\n";
}
long long int n;
vector<long long int> cost;
vector<string> arr, arrr;
long long int dp[100005][2];
bool pos = false;
long long int go(long long int i, bool isrev) {
  if (i == n) {
    pos = true;
    return 0;
  }
  if (dp[i][isrev] != -1) return dp[i][isrev];
  if (i == 0) {
    return dp[i][isrev] = min(go(i + 1, false), go(i + 1, true) + cost[0]);
  }
  string X = arr[i], X1 = arr[i - 1];
  string Y = arrr[i], Y1 = arrr[i - 1];
  if (isrev) {
    long long int temp = 1e16;
    if (Y1 <= X) temp = min(temp, go(i + 1, false));
    if (Y1 <= Y) temp = min(temp, go(i + 1, true) + cost[i]);
    return dp[i][isrev] = temp;
  } else {
    long long int temp = 1e16;
    if (X1 <= X) temp = min(temp, go(i + 1, false));
    if (X1 <= Y) temp = min(go(i + 1, true) + cost[i], temp);
    return dp[i][isrev] = temp;
  }
}
void solve() {
  rd(n);
  cost.resize(n);
  arr.resize(n);
  arrr.resize(n);
  for (long long int i = 0; i < n; i++) rd(cost[i]);
  for (long long int i = 0; i < n; i++) rd(arr[i]);
  for (long long int i = 0; i < n; i++) {
    string s = arr[i];
    reverse(s.begin(), s.end());
    arrr[i] = s;
  }
  long long int ans = (go(0, false));
  if (!pos)
    pp(-1);
  else
    pp(ans);
  return;
}
int32_t main() {
  memset(dp, -1, sizeof(dp));
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  solve();
  return 0;
}
