#include <bits/stdc++.h>
using namespace std;
long long dp[100001][2];
string s[100001][2];
int c[100001];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++) {
    cin >> s[i][0];
    s[i][1] = s[i][0];
    reverse(s[i][1].begin(), s[i][1].end());
    for (int j = 0; j < 2; j++) {
      dp[i][j] = 1e18;
      for (int k = 0; k < 2; k++) {
        if (s[i][j] >= s[i - 1][k]) {
          dp[i][j] = min(dp[i][j], dp[i - 1][k] + c[i] * j);
        }
      }
    }
  }
  if (min(dp[n][0], dp[n][1]) == 1e18)
    cout << -1;
  else
    cout << min(dp[n][0], dp[n][1]);
}
