#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  long long dp[n][2];
  for (int i = 0; i < n; i++) {
    dp[i][0] = 1e18;
    dp[i][1] = 1e18;
  }
  dp[0][0] = 0;
  dp[0][1] = a[0];
  for (int i = 1; i < n; i++) {
    string cur = s[i], prev = s[i - 1];
    string r_cur = cur, r_prev = prev;
    reverse((r_cur).begin(), (r_cur).end());
    reverse((r_prev).begin(), (r_prev).end());
    if (cur >= prev) {
      dp[i][0] = min(dp[i][0], dp[i - 1][0]);
    }
    if (r_cur >= prev) {
      dp[i][1] = min(dp[i][1], dp[i - 1][0] + a[i]);
    }
    if (r_cur >= r_prev) {
      dp[i][1] = min(dp[i][1], dp[i - 1][1] + a[i]);
    }
    if (cur >= r_prev) {
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    }
  }
  long long ans = min(dp[n - 1][0], dp[n - 1][1]);
  if (ans == 1e18) {
    ans = -1;
  }
  cout << ans;
  return 0;
}
