#include <bits/stdc++.h>
using namespace std;
long long int solve(int n, int c[], string strings[]) {
  vector<vector<long long int>> dp(n, vector<long long int>(2, LONG_LONG_MAX));
  dp[0][0] = 0;
  dp[0][1] = c[0];
  for (int i = 1; i < n; i++) {
    string temp = strings[i - 1];
    reverse(temp.begin(), temp.end());
    string t = strings[i];
    reverse(t.begin(), t.end());
    if (strings[i] >= strings[i - 1] || strings[i] >= temp) {
      if (strings[i] >= strings[i - 1] && dp[i - 1][0] != LONG_LONG_MAX) {
        dp[i][0] = min(dp[i][0], dp[i - 1][0]);
      }
      if (strings[i] >= temp && dp[i - 1][1] != LONG_LONG_MAX) {
        dp[i][0] = min(dp[i][0], dp[i - 1][1]);
      }
    }
    if (t >= strings[i - 1] || t >= temp) {
      if (t >= strings[i - 1] && dp[i - 1][0] != LONG_LONG_MAX)
        dp[i][1] = min(dp[i][1], dp[i - 1][0] + c[i]);
      if (t >= temp && dp[i - 1][1] != LONG_LONG_MAX)
        dp[i][1] = min(dp[i][1], dp[i - 1][1] + c[i]);
    }
    if (dp[i][0] == LONG_LONG_MAX && dp[i][1] == LONG_LONG_MAX) return -1;
  }
  return min(dp[n - 1][0], dp[n - 1][1]);
}
int main() {
  int n;
  cin >> n;
  int c[n];
  for (int i = 0; i < n; i++) cin >> c[i];
  string strings[n];
  for (int i = 0; i < n; i++) cin >> strings[i];
  cout << solve(n, c, strings);
  return 0;
}
