#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> cost(n);
  vector<string> words(n), rev(n);
  for (int i = 0; i < n; ++i) cin >> cost[i];
  for (int i = 0; i < n; ++i) {
    cin >> words[i];
    rev[i] = words[i];
    reverse(rev[i].begin(), rev[i].end());
  }
  vector<vector<long long> > dp(n, vector<long long>(2));
  dp[0][0] = 0;
  dp[0][1] = cost[0];
  for (int i = 1; i < n; ++i) {
    dp[i][0] = 1e18, dp[i][1] = 1e18;
    if (words[i] >= words[i - 1]) dp[i][0] = dp[i - 1][0];
    if (words[i] >= rev[i - 1]) dp[i][0] = min(dp[i - 1][1], dp[i][0]);
    if (rev[i] >= words[i - 1]) dp[i][1] = cost[i] + dp[i - 1][0];
    if (rev[i] >= rev[i - 1]) dp[i][1] = min(cost[i] + dp[i - 1][1], dp[i][1]);
    if (dp[i][0] == 1e18 && dp[i][1] == 1e18) {
      cout << "-1\n";
      return 0;
    }
  }
  cout << min(dp[n - 1][0], dp[n - 1][1]) << "\n";
  return 0;
}
