#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const long long inf64 = 1e18 + 100;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<long long> c(n);
  vector<string> strings(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> strings[i];
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(2, inf64));
  dp[1][0] = 0;
  dp[1][1] = c[0];
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < 2; j++) {
      string s = strings[i - 1], s2 = strings[i - 2];
      if (j == 1) {
        reverse(s.begin(), s.end());
      }
      for (int k = 0; k < 2; k++) {
        if (k == 1) {
          reverse(s2.begin(), s2.end());
        }
        if (s >= s2) {
          if (j == 1) {
            dp[i][j] = min(dp[i][j], dp[i - 1][k] + c[i - 1]);
          } else {
            dp[i][j] = min(dp[i][j], dp[i - 1][k]);
          }
        }
      }
    }
  }
  if (min(dp[n][0], dp[n][1]) == inf64) {
    cout << -1 << "\n";
    return 0;
  }
  cout << min(dp[n][0], dp[n][1]) << "\n";
  return 0;
}
